This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47729] Failure to receive warning message when comparing signed and unsigned integers
- From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Feb 2011 10:12:35 +0000
- Subject: [Bug c++/47729] Failure to receive warning message when comparing signed and unsigned integers
- Auto-submitted: auto-generated
- References: <bug-47729-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47729
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |ebotcazou at gcc dot
| |gnu.org
Resolution| |FIXED
Severity|normal |major
--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-02-14 10:12:24 UTC ---
> Unfortunately I don't receive warning message when comparing signed and
> unsigned integers within a function.
>
> When comparing with >, >=, < or <=, it gives me a warning message.
>
> Only when comparing with != inside a function does the warning message not
> appear.
This is rather confused. You don't get the warning on line 19 because the
function template is instantiated with n/size equal to the constant 4u, so
there is no real need to warn here.
The relevant comment in the source code of the compiler is:
/* Do not warn if the comparison is an equality operation, the
unsigned quantity is an integral constant, and it would fit
in the result if the result were signed. */