[llvm-bugs] [Bug 42203] New: clang accepts invalid code
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 8 23:02:27 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42203
Bug ID: 42203
Summary: clang accepts invalid code
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: zhonghao at pku.org.cn
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
My clang is 9.0.0, and the code is:
enum class A : unsigned long long {
z = (unsigned long long)-1
};
const A c{ A::z };
template <enum A : unsigned long long > struct Q {};
Q<c> j;
clang accepts the code. ICC rejects it:
<source>(5): error: an opaque enum declaration cannot be part of another
declaration
template <enum A : unsigned long long > struct Q {};
^
<source>(6): error: argument of type "A" is incompatible with template
parameter of type "A"
Q<c> j;
^
compilation aborted for <source> (code 2)
Compiler returned: 2
gcc also rejects it:
<source>:5:39: error: expected ';' or '{' before '>' token
5 | template <enum A : unsigned long long > struct Q {};
| ^
<source>:5:39: error: expected class-key before '>' token
<source>:6:4: note: invalid template non-type parameter
6 | Q<c> j;
| ^
Compiler returned: 1
--
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/20190609/acaee6b1/attachment.html>
More information about the llvm-bugs
mailing list