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

            Bug ID: 48538
           Summary: Template contsructor isntantiates invalid copy
                    constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: stinkingmad...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

#include<type_traits>

template<typename T>
struct S
{
    template<typename U = int,
        std::enable_if_t<std::is_const_v<T>, U> = 0>
    S(S<std::remove_const_t<T>>) {}
};

void foo(S<char>) {}

Will yield the error

<source>:8:32: error: copy constructor must pass its first argument by
reference
    S(S<std::remove_const_t<T>>) {}
                               ^
                                const &
<source>:11:17: note: in instantiation of template class 'S<char>' requested
here
void foo(S<char>)

I believe the snippet is well-formed due to either [class.copy.ctor]/5

> A declaration of a constructor for a class X is ill-formed if its first 
> parameter is of type cv X and
> either there are no other parameters or else all other parameters have 
> default arguments.
> A member function template is never instantiated to produce such a 
> constructor signature.

Or simply because it should SFINAE away, the constructor is dependent.

-- 
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