[llvm-bugs] [Bug 35287] New: Clang rejects narrowing conversions in case labels
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 13 03:56:01 PST 2017
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: unassignedclangbugs at nondot.org
Reporter: miyuki-llvm at miyuki.ru
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171113/ad1ed3c8/attachment.html>
More information about the llvm-bugs
mailing list