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: unassignedclangb...@nondot.org
          Reporter: zhong...@pku.org.cn
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to