bug-autoconf
[Top][All Lists]
Advanced

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

Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11


From: Adrian Bunk
Subject: Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11
Date: Tue, 2 Oct 2012 00:37:14 +0300
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Sep 28, 2012 at 11:22:07AM -0700, Paul Eggert wrote:
> On 09/28/2012 05:34 AM, Adrian Bunk wrote:
> > I call it a bug that gnu99 passes the 
> > current C11 test.
> 
> Much of the problem here is that the documentation is
> not explaining the intent clearly enough.  I pushed
> the following patch to try to help with this.  This also should
> address the glitch with IBM XL C V12.1 that you noted earlier.
>...
> --- a/lib/autoconf/c.m4
> +++ b/lib/autoconf/c.m4
> @@ -1164,7 +1164,7 @@ dnl SVR4                        -Xc -D__EXTENSIONS__
>  # helps, append it to CC.  If eventually successful, run ACTION-IF-AVAILABLE,
>  # else ACTION-IF-UNAVAILABLE.
>  AC_DEFUN([_AC_C_STD_TRY],
> -[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
> +[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ 
> features])
>  AC_CACHE_VAL(ac_cv_prog_cc_$1,
>  [ac_cv_prog_cc_$1=no
>  ac_save_CC=$CC
> @@ -1347,7 +1347,9 @@ AC_DEFUN([_AC_PROG_CC_C99],
>  [_AC_C_C99_TEST_BODY],
>  dnl Try
>  dnl GCC              -std=gnu99 (unused restrictive modes: -std=c99 
> -std=iso9899:1999)
> -dnl IBM XL C -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
> +dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
> +dnl IBM XL C -qlanglvl=extc99
> +dnl          (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
>  dnl HP cc    -AC99
>  dnl Intel ICC        -std=c99, -c99 (deprecated)
>  dnl IRIX     -c99
> @@ -1364,7 +1366,7 @@ dnl             good enough.  For more, please see the 
> thread starting at:
>  dnl            
> http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
>  dnl Tru64    -c99
>  dnl with extended modes being tried first.
> -[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99]], [$1], 
> [$2])[]dnl
> +[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x 
> -qlanglvl=extc99]], [$1], [$2])[]dnl
>  ])# _AC_PROG_CC_C99
>...

Now we have two compilers that will stay in C99 mode instead of C11 mode 
if they are in C99 mode by default.

The basic problem is that from the two compilers where autoconf supports 
C11 mode setting at the moment, one of them supports more C11 features 
in C99 mode than the other one does even in C11 mode.

That problem cannot be solved by just shifting compiler options back 
and forth between the C99 and C11 tests.

I think the proper solution for the C11 test would be something like
(in pseudocode [1]):

for test in test1 test2 test3
    for opt in '' -std=gnu11 -qlanglvl=extc1x
        if (run(test,opt) == SUCCESS)
            return opt
return NOT_SUPPORTED


cu
Adrian

[1] with test1 being the most strict test (e.g. the current C11 test 
    plus __STDC_VERSION__) and test3 being the least strict test

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed




reply via email to

[Prev in Thread] Current Thread [Next in Thread]