[llvm-bugs] [Bug 32913] New: Redundant warning when comparing values of different scoped enum types

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 3 12:52:53 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32913

            Bug ID: 32913
           Summary: Redundant warning when comparing values of different
                    scoped enum types
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rjmccall at apple.com
                CC: llvm-bugs at lists.llvm.org

harza:/tmp$ cat red.cpp
enum class UnscopedA { // Also happens if either (but not both) are unscoped
  SomeCase
};

enum class ScopedA {
  SomeOtherCase
};

bool compare(ScopedA a) {
  return (a == UnscopedA::SomeCase);
}

harza:/tmp$ clang++ -std=c++11 -fsyntax-only red.cpp
red.cpp:10:13: warning: comparison of two values with different enumeration
      types ('ScopedA' and 'UnscopedA') [-Wenum-compare]
  return (a == UnscopedA::SomeCase);
          ~ ^  ~~~~~~~~~~~~~~~~~~~
red.cpp:10:13: error: invalid operands to binary expression ('ScopedA' and
      'UnscopedA')
  return (a == UnscopedA::SomeCase);
          ~ ^  ~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170503/cbbea6f1/attachment.html>


More information about the llvm-bugs mailing list