[Bug c++/47729] New: Failure to receive warning message when comparing signed and unsigned integers

2011-02-14 Thread samuelmarks at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47729

   Summary: Failure to receive warning message when comparing
signed and unsigned integers
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: samuelma...@gmail.com


Created attachment 2
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=2
Commented test-case with example prominently shown

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.

Please fix this bug.

Thank you,

Samuel Marks


[Bug c++/47729] Failure to receive warning message when comparing signed and unsigned integers

2011-02-14 Thread samuelmarks at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47729

Samuel Marks  changed:

   What|Removed |Added

   Severity|normal  |major

--- Comment #2 from Samuel Marks  2011-02-14 
11:19:29 UTC ---
(In reply to comment #1)
> > 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.  */

Good point, I was thinking the same; however thought that condition would also
hold true for >, <, >=, <=...


[Bug c++/47729] Failure to receive warning message when comparing signed and unsigned integers

2011-02-14 Thread samuelmarks at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47729

Samuel Marks  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|WONTFIX |

--- Comment #4 from Samuel Marks  2011-02-14 
16:47:42 UTC ---
Since comparison between any boolean expression, not just != is valid for any
types, why have any warns at all?

Otherwise, have warns for every boolean equality expression.