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

             Bug #: 53524
           Summary: [4.7/4.8 Regression] Bogus and unsupressable enum
                    comparison warning
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ppluzhni...@google.com


Created attachment 27519
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27519
test case

Test case reduced from llvm/utils/TableGen/AsmMatcherEmitter.cpp

First noticed in gcc-4.7, confirmed in 4.8.0 20120515.

In template metaprogramming, it is quite common to compare enum values from
different instantiations of the same template.

GCC-4.7 started to warn about some of them. Further, the warning doesn't get
suppressed even under -Wno-enum-compare.

There is also a secondary problem: the diagnostic emitted is particularly lousy
-- it points to the enum itself, leaving no clue as to what GCC is complaining
about:

g++ -c tt.cc
tt.cc: In instantiation of ‘struct PointerUnionUIntTraits<CodeGenInstruction*,
CodeGenInstAlias*>’:
tt.cc:10:8:   required from ‘struct
PointerIntPair<PointerUnionUIntTraits<CodeGenInstruction*, CodeGenInstAlias*>
>’
tt.cc:23:9:   required from ‘class PointerUnion<CodeGenInstruction*,
CodeGenInstAlias*>’
tt.cc:27:61:   required from here
tt.cc:14:8: warning: enumeral mismatch in conditional expression:
‘PointerLikeTypeTraits<CodeGenInstruction*>::<anonymous enum>’ vs
‘PointerLikeTypeTraits<CodeGenInstAlias*>::<anonymous enum>’ [enabled by
default]
   enum {
        ^

Reply via email to