[llvm-bugs] [Bug 47112] New: Need a pedantic warning for switch statements with implicit default

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 11 05:01:50 PDT 2020


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

            Bug ID: 47112
           Summary: Need a pedantic warning for switch statements with
                    implicit default
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dave at znu.io
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

I learned recently that the C++ standard allows enums to contain values that
aren't valid, therefore a "covered" switch without a default might not handle
all values from the perspective of the standard.

It would be nice if this scenario had an opt-in pedantic warning. For example:

enum class Foo { A, B, C };

int exampleCoveredSwitch(Foo foo) {
        switch (foo) {
        case Foo::A: return 12;
        case Foo::B: return 34;
        case Foo::C: return 56;
        }
        // some kind of opt-in warning here about returning from a non-void
function
}

-- 
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/20200811/259d0d5d/attachment.html>


More information about the llvm-bugs mailing list