You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Liviu Nicoara <ni...@roguewave.com> on 2006/01/10 00:03:09 UTC

[PATCH] The new -Wextra breaking some gcc builds

A minor issue: -Wextra in gcc.config added for CXX_MAJOR != 2 breaks gcc
builds. AFAICT, it's a valid option starting with 3.4.x.

Liviu

2006-01-09  Liviu Nicoara  <ni...@roguewave.com>

	* etc/config/gcc.config: altered conditional
	  to add -Wextra for gcc > 3.4



Index: etc/config/gcc.config
===================================================================
--- etc/config/gcc.config       (revision 367394)
+++ etc/config/gcc.config       (working copy)
@@ -19,10 +19,12 @@
 WARNFLAGS      += -Wno-long-long
 endif   # gcc >= 2.90

-# enable additional warnings with gcc 3 and above
-ifneq ($(CXX_MAJOR),2)
+# enable additional warnings with gcc 3.4 and above
+ifeq ($(shell expr $(CXX_MAJOR) \> 2),1)
+ifeq ($(shell expr $(CXX_MINOR) \> 3),1)
   WARNFLAGS += -Wextra
 endif
+endif

 # prevent (bogus?) warnings on SunOS
 ifneq ($(OSNAME),SunOS)



Re: [PATCH] The new -Wextra breaking some gcc builds

Posted by Martin Sebor <se...@roguewave.com>.
Martin Sebor wrote:
> Liviu Nicoara wrote:
> 
>> A minor issue: -Wextra in gcc.config added for CXX_MAJOR != 2 breaks gcc
>> builds. AFAICT, it's a valid option starting with 3.4.x.
[...]
> But let me double-check that -Wextra is different than -W -- the
> manual says they are the same but I could have sworn I've seen
> it emit warnings not seen without it:
> http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Warning-Options.html#index-W-240 

They really are the same -- below is the code from gcc 4.0.2 opts.c.
I removed the option from gcc.config with r367459.

    708      case OPT_W:
    709        /* For backward compatibility, -W is the same as -Wextra.  */
    710        set_Wextra (value);
    711        break;
    712
    713      case OPT_Wextra:
    714        set_Wextra (value);
    715        break;

Martin

Re: [PATCH] The new -Wextra breaking some gcc builds

Posted by Martin Sebor <se...@roguewave.com>.
Liviu Nicoara wrote:
> A minor issue: -Wextra in gcc.config added for CXX_MAJOR != 2 breaks gcc
> builds. AFAICT, it's a valid option starting with 3.4.x.

I tested the flag with gcc 3.0 and it didn't object, but now I see
that it doesn't seem to mind just about anything:

$    echo "int main () { }" > t.cpp \
   && gcc -Wextra t.cpp
   && gcc -Wfoobar t.cpp
   && gcc -v

Reading specs from 
/usr/local/gcc-3.0/lib/gcc-lib/sparc-sun-solaris2.9/3.0/specs
Configured with: /build/gcc-3.0/configure --prefix=/usr/local/gcc-3.0 
--enable-languages=c,c++
Thread model: posix
gcc version 3.0


[...]
> -# enable additional warnings with gcc 3 and above
> -ifneq ($(CXX_MAJOR),2)
> +# enable additional warnings with gcc 3.4 and above
> +ifeq ($(shell expr $(CXX_MAJOR) \> 2),1)
> +ifeq ($(shell expr $(CXX_MINOR) \> 3),1)

I don't think this is quite right -- it fails to add the flag
for gcc 4.0 (and all other gcc x.y with y < 4). What we want
is:

     ifeq ($(shell expr \( $(CXX_MAJOR) \> 2 \& $(CXX_MINOR) \> 3 \) \
                        \| $(CXX_MAJOR) \> 3 ))

But let me double-check that -Wextra is different than -W -- the
manual says they are the same but I could have sworn I've seen
it emit warnings not seen without it:
http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Warning-Options.html#index-W-240

Martin