-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed Template Deduction in C++20 Designated Initializers #56394
Comments
@llvm/issue-subscribers-clang-format |
@llvm/issue-subscribers-c-20 |
@EugeneZelenko I think this is more of a clang-frontend issue than a clang-format issue :P |
@llvm/issue-subscribers-clang-frontend |
@marstaik: Sorry for my mistake. Fixed. |
I think it is because of missing deduction candidate. Here is a smaller repro (https://godbolt.org/z/b4v14T74d) template<typename T>
struct Foo {
int foo;
T bar;
};
int main() {
auto foo = Foo {1, 0.5};
return 0;
} |
Fixing this is going to be somewhat complicated Currently, template argument deduction is centered around functions. Functions cover things such as constructors. Aggregate initializers, however, do not fit this model, so I think there might be a good amount of refactoring necessary to resolve this. |
Even smaller repro: https://godbolt.org/z/xqbde4hfM template <class T>
struct S {
T t;
};
S s{.t = int(3)}; |
Tested with clang 14.0
When a template field is initialized via designated initializers, clang fails to deduce the final specialization.
Code example:
Note that this works succesfully in MSVC and GCC:
MSVC: https://godbolt.org/z/qr5a56xbs
GCC: https://godbolt.org/z/sqc4r1Eb4
clang: https://godbolt.org/z/P1c3v7Gfj
The compiler reports:
The text was updated successfully, but these errors were encountered: