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

            Bug ID: 60978
           Summary: [4.9 Regression] -Wenum-compare warns too eagerly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Test case:

enum { A };
enum { B };

int foo(int x)
{
  return x ? A : B;
}

gcc -c -Wall t.c
# no warnings

g++ -c t.c
t.c: In function ‘int foo(int)’:
t.c:6:12: warning: enumeral mismatch in conditional expression: ‘<anonymous
enum>’ vs ‘<anonymous enum>’ [-Wenum-compare]
   return x ? A : B;
            ^

First, there is nothing to warn about here (in real code, I return IPPROTO_ICMP
or IPPROTO_ICMPV66 depending on address family).

Second, why is this pointing to the comparison and references enum-compare?
There is no comparison of unrelated enums here.

Reply via email to