[llvm-bugs] [Bug 33699] New: Invalid results for -Wreturn-type, -Wcovered-switch-default dealing with enum class switch statements
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jul 6 08:09:15 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33699
Bug ID: 33699
Summary: Invalid results for -Wreturn-type,
-Wcovered-switch-default dealing with enum class
switch statements
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: tamir.bahar at gmail.com
CC: llvm-bugs at lists.llvm.org
Overview:
When using an enum-class in a switch-statement, both -Wreturn-type and
-Wcovered-switch-default give erroneous results.
Steps To Reproduce:
Compile the following code with both the warnings enabled (-Wreturn-type
-Wcovered-switch-default
enum class A{x, y};
int f(A a) {
switch (a) {
case A::x: return 0;
case A::y: return 1;
}
}
int g(A a) {
switch (a) {
case A::x: return 0;
case A::y: return 1;
default: return 2;
}
}
Actual Results:
The following warning is displayed
warning: default label in switch which covers all enumeration values
[-Wcovered-switch-default]
default: return 2;
Expected Results:
There should be no warning for the default case in function g, and there should
be a return-type warning for function f.
Clang Version:
clang version 5.0.0 (trunk 307237)
Target: x86_64-unknown-linux-gnu
Thread model: posix
--
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/20170706/a272ef1c/attachment-0001.html>
More information about the llvm-bugs
mailing list