Discussion:
C11 and C++11 support detection fails with clang
Mike Miller
2016-02-24 07:18:06 UTC
Permalink
Hi,

Testing autoconf git master with the clang compiler shows the following
unfortunate feature test results:

checking for clang-3.8 option to enable C11 features... unsupported
checking for clang-3.8 option to enable C99 features... none needed
[…]
checking for clang-3.8 option to enable C++11 features... unsupported
checking for clang-3.8 option to enable C++98 features... none needed

The attached patch fixes the error in _AC_CXX_CXX11_TEST_BODY
(initializing a char* with a string constant is a warning in gcc but an
error in clang). Look OK?

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?

Thanks,
--
mike
Mike Miller
2016-02-24 07:25:27 UTC
Permalink
Post by Mike Miller
The attached patch fixes the error in _AC_CXX_CXX11_TEST_BODY
(initializing a char* with a string constant is a warning in gcc but an
error in clang). Look OK?
Attached for real this time.
--
mike
Nick Bowler
2016-02-24 18:51:07 UTC
Permalink
On 2016-02-24, Mike Miller <***@octave.org> wrote:
[...]
Post by Mike Miller
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
Paul Eggert
2016-03-15 15:59:24 UTC
Permalink
Post by Nick Bowler
Right, the C11 standard says that the controlling expression of
_Static_assert must be an integer constant expression.
Thanks, I installed the attached into autoconf master; it should fix
these problems.
Mike Miller
2016-03-15 16:15:33 UTC
Permalink
Post by Nick Bowler
Right, the C11 standard says that the controlling expression of
_Static_assert must be an integer constant expression.
Thanks, I installed the attached into autoconf master; it should fix these
problems.
Thanks for taking care of this. I forgot to report back that this change
does resolve the problem for me.
--
mike
Loading...