<div dir="ltr"><div>Hi guys,</div><div>So I was running clang-tidy on some larger code base recently, and I got warning like this:</div><div><br></div><div><br></div><div><br></div><div>warning: optimization flag '-fno-inline-functions-called-once' is not supported [clang-diagnostic-ignored-optimization-argument]</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:18:26: warning: Called C++ object pointer is uninitialized [clang-analyzer-core.CallAndMessage]</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div>                         ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:13:8: note: Assuming 'pos' is not equal to 'npos'</div><div>    if(pos == std::string::npos)</div><div>       ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:13:5: note: Taking false branch</div><div>    if(pos == std::string::npos)</div><div>    ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:18:28: note: '__range' initialized to a garbage value</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div>                           ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:18:26: note: Called C++ object pointer is uninitialized</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div>                         ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:18:26: warning: This statement is never executed [clang-analyzer-alpha.deadcode.UnreachableCode]</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div>                         ^</div><div>/home/ppadlewski/fast-clang/Components/Stats/Aggregate.cc:18:26: note: This statement is never executed</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div><br></div><div><br></div><div><br></div><div>Code looks like this:</div><div><div>void parseAggregate(std::string& key, std::vector<std::string>& values, const std::string& aggregate)</div><div>{</div><div>    std::string::size_type pos = aggregate.find('=');</div><div>    if(pos == std::string::npos)</div><div>        throw FastException("Expected \"key=value,value...\" format.");</div><div>    key = aggregate.substr(0, pos);</div><div>    values.clear();</div><div>    typedef boost::tokenizer<boost::char_separator<char>> tokenizer;</div><div>    for(const auto& token: tokenizer(aggregate.begin()+pos+1, aggregate.end(), boost::char_separator<char>(",")))</div><div>        values.push_back(token);</div><div>}</div></div><div><br></div><div>Is it bug in the analyzer, or boost::tokenizer is broken? (1.55)</div><div><br></div><div>Best</div><div>Piotr Padlewski</div></div>