* Extra warning
@ 2002-08-07 11:14 Jeremy Sanders
2002-08-07 11:21 ` Neil Booth
0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Sanders @ 2002-08-07 11:14 UTC (permalink / raw)
To: gcc
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Extra warning
2002-08-07 11:14 Extra warning Jeremy Sanders
@ 2002-08-07 11:21 ` Neil Booth
0 siblings, 0 replies; 2+ messages in thread
From: Neil Booth @ 2002-08-07 11:21 UTC (permalink / raw)
To: Jeremy Sanders; +Cc: gcc
Jeremy Sanders wrote:-
> 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).
If you'd really like this addressed at some time in the future,
please file a PR (gcc.gnu.org/bugs.html). Otherwise it will be
forgotten.
Neil.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-07 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-07 11:14 Extra warning Jeremy Sanders
2002-08-07 11:21 ` Neil Booth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).