https://bugs.llvm.org/show_bug.cgi?id=35287
Bug ID: 35287
Summary: Clang rejects narrowing conversions in case labels
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Keywords: compile-fail
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: miyuki-l...@miyuki.ru
CC: llvm-bugs@lists.llvm.org
Consider the following test case:
$ cat test.cc
int main() {
switch (0u) {
case -1: break;
}
}
Clang rejects this code when compiling in C++11 and later modes with the
following error:
$ clang++ -std=c++11 -fsyntax-only test.cc
test.cc:3:10: error: case value evaluates to -1, which cannot be narrowed to
type 'unsigned int' [-Wc++11-narrowing]
case -1: break;
^
GCC and EDG (ICC 18) accept this code: https://godbolt.org/g/hVWQgW
ISTM that Clang is wrong (nothing in [stmt.switch] suggests that narrowing
conversions are not allowed in case labels).
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs