This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52763] New: Warning if compare between enum and non-enum type
- From: "gccreports at gmx-topmail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Mar 2012 07:56:23 +0000
- Subject: [Bug c++/52763] New: Warning if compare between enum and non-enum type
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52763
Bug #: 52763
Summary: Warning if compare between enum and non-enum type
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gccreports@gmx-topmail.de
Hi,
the following program doesn't create a warning. It would be nice to get an
warning each time a enumeration type is compared to a non enumeration type,
because it forces better readable code (at least in my opinion).
I compiled this with 'g++ -Wall -Wextra -Wconversion -Werror'.
Best regards,
Mikka
typedef enum {
NONE = 0, ONE = 1, TWO = 2
} tEnumType;
int main(void){
tEnumType var1 = TWO;
//Warn here, because we compare an enum to a non-enum type (1)
//should be 'if (var1 == ONE)'
if (var1 == 1)
return 1;
else
return 0;
}