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

Reply via email to