https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128816

            Bug ID: 128816
           Summary: static_assert in pedantic C17 allows omitting 2nd
                    parameter
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roman.zilka at gmail dot com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

C17 requires that _Static_assert have a second parameter with a string literal.
GCC enforces that with -std=c17 -pedantic, but fails to do so when the macro
static_assert is used. Applies to C11, too, I suppose.

$ cat stassert_c17.c 
_Static_assert(1<2);
int main() {}
$ gcc -std=c17 -pedantic stassert_c17.c
stassert_c17.c:1:1: warning: ISO C11 does not support omitting the string in
‘_Static_assert’ [-Wpedantic]
    1 | _Static_assert(1<2);
      | ^~~~~~~~~~~~~~
$ 

$ cat stassert_c17.c 
#include <assert.h>
static_assert(1<2);
int main() {}
$ gcc -std=c17 -pedantic stassert_c17.c
$ 

gcc (Gentoo Hardened 16.2.1_p20260926 p1) 16.2.1 20260926
glibc 2.43
  • [Bug c/128816] New: static_asser... roman.zilka at gmail dot com via Gcc-bugs

Reply via email to