C11 and C++11 support detection fails with clang

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

C11 and C++11 support detection fails with clang

Mike Miller
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

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|

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

Mike Miller
On Tue, Feb 23, 2016 at 23:18:06 -0800, Mike Miller wrote:
> 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

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

autoconf-cxx11.diff (525 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Nick Bowler-2
In reply to this post by Mike Miller
On 2016-02-24, Mike Miller <[hidden email]> 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
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|

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

Paul Eggert
On 02/24/2016 10:51 AM, Nick Bowler wrote:
> 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.

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

0001-Port-C11-and-C-11-testing-to-clang.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Mike Miller
On Tue, Mar 15, 2016 at 08:59:24 -0700, Paul Eggert wrote:
> On 02/24/2016 10:51 AM, Nick Bowler wrote:
> >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

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf