The problem seems to be because the textfunction has a parameter named function which seems to collide with the std::function parameter type passed to std::unique_ptr. If I rename the parameter so it's not called "function" , like void text(std::function<void()> foonction) then cppcheck doesn't report an internal error.
In checkunusedfunctions.cpp when the next token is < then ftok = ftok->link() is called, but the value of mNextseems to be invalid or null, as the following call to Token::Match prints the error.
// funcname ( => Assert that the end parentheses isn't followed by {if(Token::Match(funcname,"%name% (|<")){constToken*ftok=funcname->next();if(ftok->str()=="<")ftok=ftok->link();if(Token::Match(ftok->linkAt(1),") const|throw|{"))funcname=nullptr;}
Pedro
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks!
cppcheck-2.6 crashes for me with a segmentation fault. I do not get any crash in cppcheck HEAD but I wonder if the bug is fixed . Need to investigate a bit why I don't get the crash with head.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It used to crash for me, too (I got an Internal error, received signal 11) but it was mostly when I was calling cppcheck with -j20. To debug the problem I isolated the problematic file and that's when I saw the "Internal error: linkat called with index outside the tokens range".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
cppcheck 2.6.1 reports
error: Internal error. Token::linkAt called with index outside the tokens range. [cppcheckError]
. This didn't happen in 2.5.I narrowed it down to this:
The problem seems to be because the
text
function has a parameter namedfunction
which seems to collide with thestd::function
parameter type passed tostd::unique_ptr
. If I rename the parameter so it's not called "function" , likevoid text(std::function<void()> foonction)
then cppcheck doesn't report an internal error.In
checkunusedfunctions.cpp
when the next token is<
thenftok = ftok->link()
is called, but the value ofmNext
seems to be invalid or null, as the following call to Token::Match prints the error.Pedro
Thanks!
cppcheck-2.6 crashes for me with a segmentation fault. I do not get any crash in cppcheck HEAD but I wonder if the bug is fixed . Need to investigate a bit why I don't get the crash with head.
It used to crash for me, too (I got an Internal error, received signal 11) but it was mostly when I was calling cppcheck with -j20. To debug the problem I isolated the problematic file and that's when I saw the "Internal error: linkat called with index outside the tokens range".