Simple example:
#define NUM_CHAR(str) str##_numch inline auto operator "" _numch(const char *ch, std::size_t size) noexcept -> std:size_t { return size; } int main(void) { auto x = NUM_CHAR("abc"); }
Produces on Cppcheck 1.87 : (error) failed to expand 'NUM_CHAR', Invalid ## usage when expanding 'NUM_CHAR'.
Expected behaviour is that this does not produce an error.
Running Cppcheck on the code with macro expanded does not produce any error:
inline auto operator "" _numch(const char *ch, std::size_t size) noexcept -> std:size_t { return size; } int main(void) { auto x = "abc"_numch; }
Note that this only occurs for pasting string constants, the following does not produce any error:
#define HALF(num) num##_half inline auto operator "" _half(long double num) noexcept -> long double { return 0.5 * num; } int main(void) { auto x = HALF(100.0); }
Looked into this briefly. Appears to be an issue with simplecpp, rather than cppcheck.
yes that sounds reasonable. simplecpp ensures that ## output is a valid token. Can you please report this in the simplecpp issue tracker: https://github.com/danmar/simplecpp/issues
##
I would assume that an invalidHashHash exception is thrown somewhere in expandHashHash: https://github.com/danmar/simplecpp/blob/master/simplecpp.cpp#L1798 Feel free to fix this.
invalidHashHash
expandHashHash
Log in to post a comment.
Simple example:
Produces on Cppcheck 1.87 :
(error) failed to expand 'NUM_CHAR', Invalid ## usage when expanding 'NUM_CHAR'.
Expected behaviour is that this does not produce an error.
Running Cppcheck on the code with macro expanded does not produce any error:
Note that this only occurs for pasting string constants, the following does not produce any error:
Looked into this briefly.
Appears to be an issue with simplecpp, rather than cppcheck.
yes that sounds reasonable. simplecpp ensures that
##
output is a valid token. Can you please report this in the simplecpp issue tracker: https://github.com/danmar/simplecpp/issuesI would assume that an
invalidHashHash
exception is thrown somewhere inexpandHashHash
: https://github.com/danmar/simplecpp/blob/master/simplecpp.cpp#L1798Feel free to fix this.