I believe having a check for detecting non-portable constant expression would be a useful addition to cppcheck. For example:
staticconstchara1='a';staticconstchara2=a1;
Will compile under both GCC and Clang without any warnings (even with -std=c89 -Wpedantic) but will straight up fail to compile under smaller compilers such as TCC.
This is because the C standard specifies that the initializer element of an object of static storage duration must be a constant expression, however it also specifies that implementations are allowed to pick their own form of constant expression.
It would be nice if cppcheck can detect usage of constant expression which are not explicitly defined in the C standard under it's portability checks. Here's a couple more examples:
Hi,
I believe having a check for detecting non-portable constant expression would be a useful addition to cppcheck. For example:
Will compile under both GCC and Clang without any warnings (even with -std=c89 -Wpedantic) but will straight up fail to compile under smaller compilers such as TCC.
This is because the C standard specifies that the initializer element of an object of static storage duration must be a constant expression, however it also specifies that implementations are allowed to pick their own form of constant expression.
It would be nice if cppcheck can detect usage of constant expression which are not explicitly defined in the C standard under it's portability checks. Here's a couple more examples: