First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 32102
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Michael Elizabeth Chastain <mec@google.com>
Add CC:
CC:
Remove selected CCs
Build:
Patch URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 32102 depends on: Show dependency tree
Show dependency graph
Bug 32102 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-01-18 19:02 Opened: 2007-05-27 02:46
This is with the 4.3-20070525 snapshot.

Test program:

void Alpha();

void Beta() {
  int i;
  for (i = 1; i > 0; ++i)
    Alpha();
}

This invocation produces no warnings:

/home/mec/gcc-4.3-20070525/install/bin/gcc -O2 -S -Wstrict-overflow=2 -Wall
z1.c

This invocation produces warnings:

/home/mec/gcc-4.3-20070525/install/bin/gcc -O2 -S -Wall -Wstrict-overflow=2
z1.c
z1.c: In function 'Beta':
z1.c:5: warning: assuming signed overflow does not occur when simplifying
conditional to constant

It looks like -Wall sets the strict overflow warning level to 1, quietly
stomping on the earlier setting.

------- Comment #1 From Andrew Pinski 2007-05-27 03:45 -------
I don't think this is a bug, -Wall enable -Wstrict-overflow=1 so you have
-Wstrict-overflow=2 -Wstrict-overflow=1 (-Wstrict-overflow is the same as
-Wstrict-overflow=2).  This is just like any other option like -fno-tree-vrp
-O2.

------- Comment #2 From Ian Lance Taylor 2007-05-29 13:48 -------
I think that having -Wall clobber -Wstrict-overflow in this way is confusing. 
This isn't reversing the setting of the option, it's changing its level.

------- Comment #3 From Manuel López-Ibáñez 2008-01-18 18:44 -------
*** Bug 34843 has been marked as a duplicate of this bug. ***

------- Comment #4 From Ismail "cartman" Donmez 2008-01-18 18:46 -------
I think then -Wall shouldn't enable -Wstrict-overflow at all. Because current
situation is counter intuitive.

------- Comment #5 From Manuel López-Ibáñez 2008-01-18 19:02 -------
(In reply to comment #4)
> I think then -Wall shouldn't enable -Wstrict-overflow at all. Because current
> situation is counter intuitive.
> 

This a bug. A quick fix is:

Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c        (revision 131530)
+++ gcc/c-opts.c        (working copy)
@@ -403,7 +403,8 @@
       warn_switch = value;
       set_Wstrict_aliasing (value);
       warn_address = value;
-      warn_strict_overflow = value;
+      if (warn_strict_overflow < 2)
+        warn_strict_overflow = value;
       warn_array_bounds = value;

       /* Only warn about unknown pragmas that are not in system

As you can see above, the same happens for other options, e.g.,
-Wstrict-aliasing=2 -Wall.

My proposal to fix this is here: 
http://gcc.gnu.org/ml/gcc/2007-05/msg00719.html
http://gcc.gnu.org/ml/gcc/2007-05/msg00724.html

------- Comment #6 From Ismail "cartman" Donmez 2008-01-18 19:11 -------
Manu,

Your fix looks quite obvious, could you send it to gcc-patches so we can fix
this before the freeze? Thanks for the quick fix btw.

Regards,
ismail

------- Comment #7 From Manuel López-Ibáñez 2008-01-19 01:40 -------
(In reply to comment #6)
> 
> Your fix looks quite obvious, could you send it to gcc-patches so we can fix
> this before the freeze? Thanks for the quick fix btw.
> 

That fix is too simple. It doesn't handle -Wno-strict-overflow -Wall, for
example. It also needs testcases.

I am testing a better patch.

------- Comment #8 From Manuel López-Ibáñez 2008-01-20 13:38 -------
(In reply to comment #2)
> I think that having -Wall clobber -Wstrict-overflow in this way is confusing. 
> This isn't reversing the setting of the option, it's changing its level.
> 

Ian, should the above testcase actually give a warning? I am testing revision
131656 and I cannot get a warning no matter what value of -Wstrict-overflow or
optimisation level I try.

------- Comment #9 From Manuel López-Ibáñez 2008-01-21 01:10 -------
*** Bug 34841 has been marked as a duplicate of this bug. ***

------- Comment #10 From Ian Lance Taylor 2008-01-21 20:40 -------
This test case will give a warning with mainline with -Wstrict-overflow (aka
-Wstrict-overflow=2) but not with -Wall (which implies -Wstrict-overflow=1).

void Alpha();

void Beta() {
  int i;
  for (i = 1; i > 0; i += i)
    Alpha();
}

------- Comment #11 From Manuel López-Ibáñez 2008-01-21 20:54 -------
(In reply to comment #10)
> This test case will give a warning with mainline with -Wstrict-overflow (aka
> -Wstrict-overflow=2) but not with -Wall (which implies -Wstrict-overflow=1).
> 

I think that testcase is structurally equivalent to the one I have included in
my proposed (and unreviewed, ;-) patch.

------- Comment #12 From Manuel López-Ibáñez 2008-01-22 14:12 -------
Subject: Bug 32102

Author: manu
Date: Tue Jan 22 14:11:44 2008
New Revision: 131720

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131720
Log:
2008-01-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR 32102
        * doc/invoke.texi (-Wall): -Wall enables -Wstrict-overflow=1.
        * flags.h (warn_strict_aliasing): Remove.
        (warn_strict_overflow): Remove.
        * opts.c (warn_strict_aliasing): Remove.
        (warn_strict_overflow): Remove.
        * c-opts.c (c_common_handle_option): -Wall only sets
        -Wstrict-aliasing or -Wstrict-overflow if they are uninitialized.
        (c_common_post_options): Give default values to -Wstrict-aliasing
        and -Wstrict-overflow if they are uninitialized.
        * common.opt (Wstrict-aliasing): Specify Var and Init.
        (Wstrict-overflow): Likewise.

testsuite/
        * gcc.dg/Wstrict-overflow-21.c: New.
        * g++.dg/warn/Wstrict-aliasing-8.C: New.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-opts.c
    trunk/gcc/common.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/flags.h
    trunk/gcc/opts.c
    trunk/gcc/testsuite/ChangeLog

------- Comment #13 From Manuel López-Ibáñez 2008-01-22 14:19 -------
Subject: Bug 32102

Author: manu
Date: Tue Jan 22 14:19:01 2008
New Revision: 131722

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131722
Log:
Missed testcases in earlier commit.

2008-01-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR 32102
testsuite/
        * gcc.dg/Wstrict-overflow-21.c: New.
        * g++.dg/warn/Wstrict-aliasing-8.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C
    trunk/gcc/testsuite/gcc.dg/Wstrict-overflow-21.c

------- Comment #14 From Manuel López-Ibáñez 2008-01-22 14:22 -------
When you try to do things faster, you end up taking more time.

Anyway, fixed for GCC 4.3.

Ian, 

do you think this should/could be backported to GCC 4.2 or should we just close
it as fixed?

------- Comment #15 From Ian Lance Taylor 2008-01-23 05:21 -------
I would be in favor of backporting to the gcc 4.2 branch.  The option is new in
gcc 4.2, and this will make it less confusing to use.

------- Comment #16 From Manuel López-Ibáñez 2008-01-27 18:37 -------
Subject: Bug 32102

Author: manu
Date: Sun Jan 27 18:36:59 2008
New Revision: 131887

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131887
Log:
2008-01-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR 32102
        * flags.h (warn_strict_aliasing): Remove.
        (warn_strict_overflow): Remove.
        * opts.c (warn_strict_aliasing): Remove.
        (warn_strict_overflow): Remove.
        * c-opts.c (c_common_handle_option): -Wall only sets
        -Wstrict-aliasing or -Wstrict-overflow if they are uninitialized.
        (c_common_post_options): Give default values to -Wstrict-aliasing
        and -Wstrict-overflow if they are uninitialized.
        * common.opt (Wstrict-aliasing): Specify Var and Init.
        (Wstrict-overflow): Likewise.

testsuite/
        * gcc.dg/Wstrict-overflow-21.c: New.
        * g++.dg/warn/Wstrict-aliasing-8.C: New.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C
    branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/Wstrict-overflow-21.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/c-opts.c
    branches/gcc-4_2-branch/gcc/common.opt
    branches/gcc-4_2-branch/gcc/flags.h
    branches/gcc-4_2-branch/gcc/opts.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

------- Comment #17 From Manuel López-Ibáñez 2008-01-27 18:39 -------
Fixed in GCC 4.2.3

First Last Prev Next    No search results available      Search page      Enter new bug