[llvm-bugs] [Bug 46551] Template deduction fails when deduction partially disabled
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jul 2 22:27:31 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46551
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
Per [temp.deduct.call]p4 and [temp.deduct.type]p1 in the C++ standard, template
argument deduction is expected to pick template arguments that make the
argument type A be the same as the "deduced A" type formed by substituting in
the deduced template argument types, for each P/A pair that participates in
deduction.
In this case, that doesn't happen. We deduce T = int and N = -1, but then (as
Clang's diagnostic says) we find that the first argument type is Span<int> but
the deduced parameter type is Span<const int>, which doesn't match. So
deduction fails.
This is a bit of an unusual case: if the first parameter were instead
"std::type_identity_t<Span<const T>>" (and the N parameter were removed), then
deduction would succeed, because the first parameter would not participate in
deduction. This special check only really matters in cases where a parameter
*partially* participates in deduction.
The fact that GCC accepts this appears to be a divergence from the standard's
rules (though I don't know if it's intentional or an oversight on their part);
they presumably don't implement the post-deduction check in question.
--
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/20200703/23a352ff/attachment.html>
More information about the llvm-bugs
mailing list