Bug 51457 - Add warning about impossible boolean comparisons
Summary: Add warning about impossible boolean comparisons
Status: RESOLVED DUPLICATE of bug 44077
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 20:27 UTC by Jack Lloyd
Modified: 2011-12-14 23:09 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Lloyd 2011-12-07 20:27:00 UTC
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.
Comment 1 Andrew Pinski 2011-12-14 23:09:55 UTC
Dup of bug 44077

*** This bug has been marked as a duplicate of bug 44077 ***