I have the following scenario:
// test.cpp #include <array> template<typename T> inline constexpr std::array<T, 1> cArray = std::array<T, 1>({T()}); template<typename T> void foo(const T& aValue) { if (cArray<T>[0] <= aValue) { return; } }
In this scenario I have a templated constant that evaluates to an std::array. Performing a comparison against the contents of the std::array results in an internalAstError. Here are the cppcheck results:
std::array
internalAstError
Checking test.cpp ... test.cpp:15:8: error: Syntax Error: AST broken, 'if' doesn't have two operands. [internalAstError] if (cArray<T>[0] <= aValue)
Storing the comparison in a bool results in this error:
bool
Checking test.cpp ... test.cpp:10:10: error: Uninitialized variable: comparison [legacyUninitvar] bool comparison = (cArray<T>[0] <= aValue);
It looks like cppcheck may be having trouble with a templated variable that evaluates to an std::array? I hope this information helps, thanks!
EDIT: Posted faulty code on accident, however it should be fixed now
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11453
Thank you so much!
Log in to post a comment.
I have the following scenario:
In this scenario I have a templated constant that evaluates to an
std::array
. Performing a comparison against the contents of thestd::array
results in aninternalAstError
. Here are the cppcheck results:Storing the comparison in a
bool
results in this error:It looks like cppcheck may be having trouble with a templated variable that evaluates to an
std::array
? I hope this information helps, thanks!EDIT: Posted faulty code on accident, however it should be fixed now
Last edit: Muhammad Javed 2022-12-20
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11453
Thank you so much!