[llvm-bugs] [Bug 42330] cosntexpr constructor breaks out expression SFINAE
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 19 15:42:09 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42330
Zhihao Yuan <lichray at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #6 from Zhihao Yuan <lichray at gmail.com> ---
(In reply to Richard Smith from comment #5)
>
> I think what's going on here is:
>
> * When initializing the array, Clang and GCC think the conversion from the
> list element to the array element type happens "inside" the braces
> * When initializing the class with the constructor, Clang (but not GCC)
> thinks the conversion from the list element to the parameter type happens
> "outside" the braces
>
> Unfortunately, I think that the second point is a bug. Consider a case such
> as this:
>
> template<int N> struct X {
> constexpr operator int() { return N; };
> };
>
> using V = __best_match_t<X<123>, short>;
>
> Here, in order to tell whether the list-initialization is valid, we may need
> to evaluate the call to X<123>::operator int(), so we should instantiate it.
Agreed.
> So I think your workaround just "happens to work". (And it doesn't work for
> GCC, which only accepts the above case [...]
Yes, the intention is to reject V.
So the conclusion in my mind is that this constructor
template <class U>
constexpr
MyPtr(MyPtr<U> v) : ptr_(v.ptr_) {}
is just not sfinae-friendly.
--
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/20190619/ef049a42/attachment.html>
More information about the llvm-bugs
mailing list