[llvm-bugs] [Bug 48538] New: Template contsructor isntantiates invalid copy constructor
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 17 03:23:25 PST 2020
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: unassignedclangbugs at nondot.org
Reporter: stinkingmadgod at gmail.com
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
#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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201217/7f0556fa/attachment.html>
More information about the llvm-bugs
mailing list