https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109523
Bug ID: 109523
Summary: List-initializing constructor of std::vector is
selected erroneously
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following program
#include <vector>
struct C {
int a;
constexpr C() : a(0) {}
constexpr C(int a) : a(a) {}
};
static_assert( std::vector<C>({5}).size() == 5 );
is accepted in Clang and MSVC. But in GCC static assertion fails, because it
constructs a vector of single element 5. Online demo:
https://gcc.godbolt.org/z/j4b3z5xxP
Related discussion with explanation:
https://stackoverflow.com/q/76013629/7325599