This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Can't turn off overflow_warning?
- From: Bradley Lucier <lucier at math dot purdue dot edu>
- To: gcc at gcc dot gnu dot org
- Cc: Bradley Lucier <lucier at math dot purdue dot edu>
- Date: Fri, 15 Jul 2005 21:27:35 -0500
- Subject: Can't turn off overflow_warning?
After examining the source and documentation, it appears to me that in
4.0.* and on mainline one cannot turn off the warning generated by
overflow_warning, in, for example,
[descartes:~] lucier% cat test.c
#include <stdio.h>
int main() {
if (1048256 * 1048256 < 0)
printf("1");
else
printf("2");
return 0;
}
[descartes:~] lucier% /pkgs/gcc-4.0.0/bin/gcc -v
Using built-in specs.
Target: powerpc-apple-darwin8.1.0
Configured with: ../configure --prefix=/pkgs/gcc-4.0.0
--with-gmp=/pkgs/gmp-4.1.3 --with-mpfr=/pkgs/gmp-4.1.3
Thread model: posix
gcc version 4.0.0
[descartes:~] lucier% /pkgs/gcc-4.0.0/bin/gcc -O1 -Wall -W -Wextra
-fwrapv test.c
test.c: In function 'main':
test.c:4: warning: integer overflow in expression
[descartes:~] lucier% ./a.out
1[descartes:~] lucier%
I'd like to be able to do this, since I'm auto-generating code that
explicitly uses overflow tests that assume that signed ints overflow
using twos-complement arithmetic and I don't want to be distracted by
extraneous warnings when constant propagation in the Scheme system puts
constants into this C code.
Personally, I'd like overflow_warning to be turned off for signed ints
if -fwrapv is passed as a flag. I suppose an explicit
-Wno-overflow-warning would be OK, too.
If I were to propose a patch, which way should I go?
Brad