Re: C11 and C++11 support detection fails with clang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2016-02-24, Mike Miller <mtmiller@xxxxxxxxxx> wrote:
[...]
> The C11 feature tests fail with the following:
>
>   conftest.c:191:19: error: static_assert expression is not an integral
> constant expression
>     _Static_assert (&v1.i == &v1.w.k, "Anonymous union alignment botch");
>
> This seems like a valid diagnostic if I'm reading the standard right,
> even though gcc permits it. I'm not sure what can replace it, but simply
> removing the assertion allows the rest of the test to pass. Any other
> ideas?

Right, the C11 standard says that the controlling expression of
_Static_assert must be an integer constant expression.  The expression
above contains address constants that are evaluated, so it is not an
integer constant expression.

The test could be rewritten using offsetof (untested):

  _Static_assert(offsetof(struct anonymous, i)
                   == offsetof(struct anonymous, w.k),
		 "Anonymous union alignment botch");

Cheers,
  Nick

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf



[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux