-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Clang choosing copy constructor over initializer_list #58520
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
@llvm/issue-subscribers-clang-frontend |
This looks like DR 2137 which reverted the change from DR 1467 which is the behavior that we are currently implementing AFAICT. The clang defect report status indicates we implemented 1467 but we have unknown status for 2137 (presumedly b/c we did not implement it). |
@llvm/issue-subscribers-c-1 |
i'd like to know if anyone started working on DR2137! |
There is a recent in-progress patch up for review at https://reviews.llvm.org/D156032 |
Duplicate of #24186. |
Uh oh!
There was an error while loading. Please reload this page.
The following short program returns '3' with clang, but '30' with GCC and '12' with MSVC.
The issue is that in lines (3) and (4), both the copy-constructor (1) and the initializer_list constructor (2) could be called.
According to cppreference.com, (2) should be called.
However, clang chooses (1) on both instances. (Interestingly, MSVC chooses (2) on (3) and (1) on (4).
This error also accurs if the constructor of S takes an initializer_list of another type T, which can be implicitly contructed from S, this is how I encountered the bug in real code.
The text was updated successfully, but these errors were encountered: