http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51457

             Bug #: 51457
           Summary: Add warning about impossible boolean comparisons
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ll...@randombit.net


Neither GCC 4.6.0 (release) and 4.7 svn (r181390) warn about the impossible
comparison in

bool f(bool b)
   {
   return (b == 'a');
   }

The optimizer figures out it is always false and will optimize it to

        xorl    %eax, %eax
        ret

>From the description in the manual I would have expected -Wtype-limits to
detect this case.

Reply via email to