This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51457] New: Add warning about impossible boolean comparisons
- From: "lloyd at randombit dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Dec 2011 20:27:00 +0000
- Subject: [Bug c++/51457] New: Add warning about impossible boolean comparisons
- Auto-submitted: auto-generated
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.