[cfe-dev] early instantiation of defaulted copy constructor
Nathan Ridge
zeratul976 at hotmail.com
Sun Apr 29 14:44:20 PDT 2012
> Hello,
>
> The following code fails to compile with Clang trunk:
>
> template <class T, class U>
> struct pair
> {
> T first;
> U second;
>
> pair() : first(), second() {}
>
> pair(const pair&) = default;
> };
>
> struct S
> {
> S() {}
> S(const S&) = delete;
> S(S&&) = default;
> };
>
> int main()
> {
> pair<int, S> p;
> }
>
> The errors are:
>
> test.cpp:9:5: error: the parameter for this explicitly-defaulted copy
> constructor is const, but a member or base requires it to be
> non-const
> pair(const pair&) = default;
> ^
> test.cpp:21:18: note: in instantiation of template class 'pair<int, S>'
> requested here
> pair<int, S> p;
> ^
>
> Thanks for the report! This issue was fixed over a week ago. Trunk
> clang accepts your code.
Ok, cool! Will it be fixed in the 3.1 branch?
Thanks,
Nate
More information about the cfe-dev
mailing list