I see crashes on Windows with following stacktrace
cppcheck_core!Token::next cppcheck_core!TemplateSimplifier::TokenAndName::TokenAndName cppcheck_core!TemplateSimplifier::getTemplateDeclarations cppcheck_core!TemplateSimplifier::simplifyTemplates cppcheck_core!Tokenizer::simplifyTemplates cppcheck_core!Tokenizer::simplifyTokenList1 cppcheck_core!Tokenizer::simplifyTokens1 cppcheck_core!CppCheck::checkFile
It happens in template specialization if there is operator < . Here is simplified example:
#include <type_traits> namespace a { template <typename T, typename enable = void> struct promote { using type = T; }; template <typename T> struct promote <T, typename std::enable_if< std::is_integral<T>::value && sizeof(T) < sizeof(int) >::type>{ }; }
I don't udersted that code. But I think this may help.
diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 46717e796..5c6b71738 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -83,8 +83,11 @@ TemplateSimplifier::TokenAndName::TokenAndName(Token *tok, const std::string &s, isAlias(paramEnd->strAt(1) == "using"); isClass(Token::Match(paramEnd->next(), "class|struct|union %name% <|{|:|;")); const Token *tok1 = nameToken->next(); - if (tok1->str() == "<") - tok1 = tok1->findClosingBracket()->next(); + if (tok1->str() == "<") { + const Token *closing = tok1->findClosingBracket(); + if (closing) + tok1 = closing->next(); + } isFunction(tok1->str() == "("); isVariable(!isClass() && Token::Match(tok1, "=|;")); if (isVariable())
Thanks, i can reproduce the crash and have created ticket https://trac.cppcheck.net/ticket/9046
Log in to post a comment.
I see crashes on Windows with following stacktrace
It happens in template specialization if there is operator < .
Here is simplified example:
I don't udersted that code. But I think this may help.
Thanks, i can reproduce the crash and have created ticket https://trac.cppcheck.net/ticket/9046