Is this a bug? _Static_assert() failed although __has_feature(c_static_assert) is false

Hi,
When compiling the following test program on my Ubuntu machine, I get a compile-time error:

/* test.c /
#if __has_feature(c_static_assert)
#pragma message(“HAS_STATIC_ASSERT”)
#else
_Static_assert(1==0,""); // if there is no static assert support
#endif
/
end of test.c */

$ install/bin/clang -S -o - test.c
test.c:4:1: error: static_assert failed “”
_Static_assert(1==0,"");
^ ~~~~
1 error generated.

Since __has_feature(c_static_assert) is false, I would not expect _Static_assert() to be enabled here. Should I file a clang bug?

Thanks,

  • Gao.

Hi,
When compiling the following test program on my Ubuntu machine, I get a compile-time error:

/* test.c /
#if __has_feature(c_static_assert)
#pragma message(“HAS_STATIC_ASSERT”)
#else
_Static_assert(1==0,""); // if there is no static assert support
#endif
/
end of test.c */

$ install/bin/clang -S -o - test.c
test.c:4:1: error: static_assert failed “”
_Static_assert(1==0,"");
^ ~~~~
1 error generated.

Since __has_feature(c_static_assert) is false, I would not expect _Static_assert() to be enabled here. Should I file a clang bug?

No; we support _Static_assert as an extension. See __has_extension(c_static_assert).