https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102502
--- Comment #3 from Fangrui Song <i at maskray dot me> --- OK, Andrew asked me to file it :) I just wanted to fix glibc and run away from the GCC inconsistency. I know that https://www.iso-9899.info/n1570.html#6.6 p10 says "An implementation may accept other forms of constant expressions." Accepting `const int` in C mode is an extension, but it seems odd to be inconsistent (-O0 and -O2 -Wpedantic reject it while -O2 allows it). % cat reduce.i const int __alloc_dir_allocation_size = 8; void __alloc_dir() { _Static_assert(__alloc_dir_allocation_size, ""); } % gcc reduce.i -c -std=c11 reduce.i: In function ‘__alloc_dir’: reduce.i:2:37: error: expression in static assertion is not constant 2 | void __alloc_dir() { _Static_assert(__alloc_dir_allocation_size, ""); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ % gcc reduce.i -c -std=c11 -O1 % gcc reduce.i -c -std=c11 -O2 % gcc reduce.i -c -std=c11 -O2 -Wpedantic reduce.i: In function ‘__alloc_dir’: reduce.i:2:37: warning: expression in static assertion is not an integer constant expression [-Wpedantic] 2 | void __alloc_dir() { _Static_assert(__alloc_dir_allocation_size, ""); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Clang just rejects it in all optimization levels. % clang reduce.i -c -std=c11 -O0 reduce.i:2:37: error: static_assert expression is not an integral constant expression void __alloc_dir() { _Static_assert(__alloc_dir_allocation_size, ""); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. % clang reduce.i -c -std=c11 -O1 reduce.i:2:37: error: static_assert expression is not an integral constant expression void __alloc_dir() { _Static_assert(__alloc_dir_allocation_size, ""); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.