Extra warning
Jeremy Sanders
jss@ast.cam.ac.uk
Wed Aug 7 11:14:00 GMT 2002
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
More information about the Gcc
mailing list