[libcxx-commits] [PATCH] D110216: [clang] retain type sugar in auto / template argument deduction
Matheus Izvekov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 16 12:55:09 PST 2021
mizvekov added a comment.
In D110216#3135461 <https://reviews.llvm.org/D110216#3135461>, @hans wrote:
> We're seeing a diagnostic change in Chromium which looks funny. For the following code (span<> is our own class):
> ....
> the diagnostic changes from:
>
> fatal error: no viable conversion from 'span<const int, [...]>' to 'span<int, [...]>
>
> to
>
> fatal error: no viable conversion from 'span<T, [...]>' to 'span<int, [...]>
>
> This looks very strange.
Hi! thanks for the report.
I am not sure how to reproduce this.
I tried mocking this situation:
template <class T> struct vector {};
template <class T, class=void> struct span {};
template <class T> auto make_span(const vector<T> &) { return span<const T>(); }
void WontCompile() {
const vector<int> v;
span<int> s1 = make_span(v);
}
Which I get:
error: no viable conversion from 'span<const int>' to 'span<int>'
Looking at the `dump` of that type:
AutoType 0x246b83676c0 'span<const int>' sugar
`-ElaboratedType 0x246b8366d60 'span<const int>' sugar
`-TemplateSpecializationType 0x246b8366d20 'span<const int>' sugar span
|-TemplateArgument type 'const int':'const int'
| `-QualType 0x246b8366751 'const int' const
| `-SubstTemplateTypeParmType 0x246b8366750 'int' sugar
| |-TemplateTypeParmType 0x246b835c790 'T' dependent depth 0 index 0
| | `-TemplateTypeParm 0x246b835c740 'T'
| `-BuiltinType 0x246b82e81e0 'int'
`-RecordType 0x246b8366d00 'struct span<const int>'
`-ClassTemplateSpecialization 0x246b8366be8 'span'
In particular, the `SubstTemplateTypeParmType` desugars to int, not `T`, and I am not sure how you managed to get that ellipsis (from the type diff) on the template specialization arguments.
I am looking though at a clang built from `D112374`, which is main with what I believe are other patches that have no effect here besides the addition of the `ElaboratedType` node on that dump.
To be sure, it's going to take me a while to get a main built here, so hopefully this is not a big problem for you right now?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110216/new/
https://reviews.llvm.org/D110216
More information about the libcxx-commits
mailing list