For example:
template<typename Word, size_t NumWords, typename Enable = typename std::enable_if<sizeof(Word) < sizeof(word_t)>::type >
Cppcheck will calculate the number of '<' and '>'. However, this symbol in 'sizeof(Word) < sizeof(word_t)' means less-than sign, and cppcheck still think it is 'garbage templates'.
/cppcheck-1.85/lib/tokenize.cpp void Tokenizer::findGarbageCode() const { ... // Garbage templates.. if (isCPP()) { for (const Token *tok = tokens(); tok; tok = tok->next()) { if (!Token::simpleMatch(tok, "template <")) continue; if (tok->previous() && !Token::Match(tok->previous(), "[:;{})>]")) syntaxError(tok); const Token * const tok1 = tok; tok = tok->next()->findClosingBracket(); if (!tok) syntaxError(tok1); if (!Token::Match(tok, ">|>> ::| %name%") && !Token::Match(tok, ">|>> [ [ %name%")) syntaxError(tok->next() ? tok->next() : tok1); } } }
if I add brances on both sides of 'sizeof(Word) < sizeof(word_t)' or add '>' in the end, the probrem will not appear.
template<typename Word, size_t NumWords, typename Enable = typename std::enable_if<(sizeof(Word) < sizeof(word_t))>::type > template<typename Word, size_t NumWords, typename Enable = typename std::enable_if<sizeof(Word) < sizeof(word_t)>::type >>
Thanks! I have created a ticket: https://trac.cppcheck.net/ticket/8812
Log in to post a comment.
For example:
Cppcheck will calculate the number of '<' and '>'. However, this symbol in 'sizeof(Word) < sizeof(word_t)' means less-than sign, and cppcheck still think it is 'garbage templates'.
if I add brances on both sides of 'sizeof(Word) < sizeof(word_t)' or add '>' in the end, the probrem will not appear.
Thanks! I have created a ticket: https://trac.cppcheck.net/ticket/8812