-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang++] Clang fails to call initializer_list constructor in specific cases #89079
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
Comments
Could you explain why you think gcc is right here? I'm not an expert on overload resolution, but at first glance, |
@llvm/issue-subscribers-clang-frontend Author: None (davidkjaer)
There seems to be a very specific case where clang does not call an initializer_list constructor even though it should apply.
The issues arises when the class `Foo` has an `std::initializer_list<Foo>` constructor and you create an object like this`Foo f{Foo{}};`:
When compiled with clang 18.1 the above example prints: On both gcc and msvc the example prints: If I switch the initialization to |
Actually, digging a bit more, this might be a duplicate of #24186 ? |
Yes. That definitely looks like a duplicate. I have deleted my previous comment since I had missed the word "aggregate" making my conclusion incorrect. No need to leave misinformation on the internet :) |
There seems to be a very specific case where clang does not call an initializer_list constructor even though it should apply.
The issues arises when the class
Foo
has anstd::initializer_list<Foo>
constructor and you create an object like thisFoo f{Foo{}};
:When compiled with clang 18.1 the above example prints:
Hello
On both gcc and msvc the example prints:
Initializer list constructor
Hello
If I switch the initialization to
Foo f{{std::move(other)}}
orFoo f{Foo{}, Foo{}}
clang correctly calls the initializer_list constructor.The text was updated successfully, but these errors were encountered: