[cfe-dev] Is this a bug? _Static_assert() failed although __has_feature(c_static_assert) is false

Richard Smith richard at metafoo.co.uk
Fri Jul 19 16:23:30 PDT 2013


On Fri, Jul 19, 2013 at 4:18 PM, Gao, Yunzhong <
yunzhong_gao at playstation.sony.com> wrote:

>  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).


> Thanks,
> - Gao.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130719/5c750313/attachment.html>


More information about the cfe-dev mailing list