[llvm-bugs] [Bug 42336] New: the check of static array initializer is strange
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 19 19:58:35 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42336
Bug ID: 42336
Summary: the check of static array initializer is strange
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:
template<int n>
class mylist
{
public:
static int result[] = { mylist<n-1>::result };
};
clang accepts the code, but gcc reject it:
error: in-class initialization of static data member ‘int mylist<n>::result []’
of incomplete type
static int result[] = { mylist<n-1>::result };
^~~~~~
I tried to remove static, and the code is modified to:
template<int n>
class mylist
{
public:
int result[] = { mylist<n-1>::result };
};
In this case, gcc accepts it, but clang rejects it:
error: array bound cannot be deduced from an in-class initializer
int result[] = { mylist<n-1>::result };
^
1 error generated.
Both compilers accept the following code:
template<int n>
class mylist
{
public:
int result[1] = { mylist<n-1>::result };
};
This can be a bug in clang?
--
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/20190620/4a259a62/attachment.html>
More information about the llvm-bugs
mailing list