[llvm-bugs] [Bug 47246] New: errors of implicitly-deleted default constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 19 23:23:54 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47246

            Bug ID: 47246
           Summary: errors of implicitly-deleted default constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.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

The following code(valid) is accepted by g++, clang++ rejects it: 

$ cat s.C

template<typename T>
struct A
{
  A() = default;
  A(A&&) = default;
  A(const A&) = default;
  T t;
};

struct B {
  B() = default;
  B(const B&){}
  B(B&&) = default;
};

typedef A<const B> C;

C get() { return C(); }

int main() {}

$ clang++ -c s.C
s.C:18:18: error: call to implicitly-deleted default constructor of 'C' (aka
'A<const B>')
C get() { return C(); }
                 ^
s.C:4:3: note: explicitly defaulted function was implicitly deleted here
  A() = default;
  ^
s.C:7:5: note: default constructor of 'A<const B>' is implicitly deleted
because field 't' of const-qualified type 'const B' would not be initialized
  T t;
    ^
1 error generated.

-- 
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/20200820/72a5a3f4/attachment-0001.html>


More information about the llvm-bugs mailing list