hightman / scws

开源免费的简易中文分词系统,PHP分词的上乘之选!
http://www.xunsearch.com/scws/
Other
1.65k stars 348 forks source link

编译报错may be used uninitialized in this function #76

Open longforrich opened 1 year ago

longforrich commented 1 year ago

rule.c:190:17: error: ‘rtail may be used uninitialized in this function [-Werror=maybe-uninitialized] rtail->next = a;



从代码里看
scws/libscws/rule.c@scws_rule_new里
rule_attr_t a, rtail; // 此处rtail未做初始化
...
/* append to the chain list */
if (r->attr == NULL)
    r->attr = rtail = a;
else
{
    rtail->next = a; // 此处使用了未初始化的变量
    rtail = a;
}
建议改成:
rule_attr_t a, rtail = NULL;
...
else
{
    if (rtail)
        rtail->next = a;
    rtail = a;
}
longforrich commented 1 year ago

暂时通过增加编译参数-no-undefined绕过