This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Extra warning
- From: Jeremy Sanders <jss at ast dot cam dot ac dot uk>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 7 Aug 2002 19:14:10 +0100 (BST)
- Subject: Extra warning
Hi,
gcc-3.1 doesn't seem to warn for the following code (even with
-Wconversion -W -Wall).
unsigned a;
double c;
a = 10;
c = -10 - a;
Which makes c 4294967276.00 rather than -20. It also doesn't warn for:
unsigned a;
int b;
double c;
a = 10;
b = -10;
c = b - a;
(which of course would be harder to warn for).
Am I missing the appropriate warning option? Would it be sensible/possible
to warn for the promotion of obvious negative integers to unsigned?
Perhaps int-unsigned should have a warning. (int+unsigned usually works if
int is -ve, but probably not according to the standard!).
Thanks
Jeremy
--
Jeremy Sanders <jss@ast.cam.ac.uk> http://www-xray.ast.cam.ac.uk/~jss/
X-Ray Group, Institute of Astronomy, University of Cambridge, UK.
Public Key Server PGP Key ID: E1AAE053