https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107104
Yann Droneaud <yann at droneaud dot fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yann at droneaud dot fr
--- Comment #3 from Yann Droneaud <yann at droneaud dot fr> ---
I'm experiencing the same issue:
#include <assert.h>
void a(int v)
{
static_assert(__builtin_constant_p(v) && v == -1, "failure");
}
GCC 13 and below complains:
<source>: In function 'a':
<source>:16:43: error: expression in static assertion is not constant
16 | static_assert(__builtin_constant_p(v) && v == -1, "failure");
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Compiler returned: 1
clang current trunk, eg above 15.0, seems to finally get it right:
<source>:16:5: error: static assertion failed due to requirement
'__builtin_constant_p(v) && v == -1': failure
static_assert(__builtin_constant_p(v) && v == -1, "failure");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:143:24: note: expanded from macro 'static_assert'
# define static_assert _Static_assert
^
1 error generated.
Compiler returned: 1
see https://godbolt.org/z/KKn6xTG8a