This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
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.
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.
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.
*** Bug 34843 has been marked as a duplicate of this bug. ***
I think then -Wall shouldn't enable -Wstrict-overflow at all. Because current situation is counter intuitive.
(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
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
(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.
(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.
*** Bug 34841 has been marked as a duplicate of this bug. ***
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(); }
(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.
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
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
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?
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.
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
Fixed in GCC 4.2.3