[cfe-dev] early instantiation of defaulted copy constructor
Richard Smith
richard at metafoo.co.uk
Sun Apr 29 13:54:52 PDT 2012
On Sun, Apr 29, 2012 at 11:59 AM, Nathan Ridge <zeratul976 at hotmail.com>wrote:
>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120429/70831027/attachment.html>
More information about the cfe-dev
mailing list