This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51457] New: Add warning about impossible boolean comparisons


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: unassigned@gcc.gnu.org
        ReportedBy: lloyd@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]