[Bug c++/12963] Wrong and misleading warning encourages writing non-portable code
bagnara at cs dot unipr dot it
gcc-bugzilla@gcc.gnu.org
Sat Nov 8 22:44:00 GMT 2003
------- Additional Comments From bagnara at cs dot unipr dot it 2003-11-08 22:44 -------
(In reply to comment #1)
> The warning is correct for this implementation and since you are compiling
with this
> implementation, you can recieve warnings (yes it would be better if it was
enabled by a -
> W* but I think it is good warning no matter what). To disable the warning use
-w (notice
> the lower case w).
If I understand correctly, -w inhibits all warning messages, which is
certainly not what I call for. The fact that, when producing code for
platforms where CHAR_BIT == 8, the test is redundant is a matter for
the optimizer (who can omit the test), not something the user should
be warned about. In general, I believe target-dependent warnings
should default to disabled. By the way, are there other target-dependent
warnings in GCC? I mean that this is the first time I meet one (unless
I am missing something).
Now try with
void*
foo(void* c) {
if (c <= (void*) 0xFFFFFFFF)
return 0;
else
return c;
}
and you will see that (notice -W -Wall)
g++ -W -Wall -c t.cc -O3 -fomit-frame-pointer -S
does not produce any warning. Yet, the produced code is,
.globl _Z3fooPv
.type _Z3fooPv, @function
_Z3fooPv:
.LFB3:
xorl %eax, %eax
ret
as expected.
Would you advocate a warning also in this case?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
More information about the Gcc-bugs
mailing list