https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107580
Bug ID: 107580 Summary: std::vector<std::string> cannot be brace initialized with -D_GLIBCXX_USE_CXX11_ABI=0 Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: vyas.ramasubramani at gmail dot com Target Milestone: --- The type of the argument to the constructor of A cannot be correctly inferred when using the old ABI: #include <string> #include <vector> struct A { A(std::string const& file_path) {} A(std::vector<std::string> const& file_path) {} }; int main() { std::string x = "hello"; std::string y = "goodbye"; // Both of the below will fail. A a{{x, y}}; A a = A({x, y}); } Here's the output from running the compilation: (test_gcc) vyasr-dt% g++ test.cpp -D_GLIBCXX_USE_CXX11_ABI=0 test.cpp: In function ‘int main()’: test.cpp:11:16: error: call of overloaded ‘A(<brace-enclosed initializer list>)’ is ambiguous 11 | A a1{{x, y}}; | ^ test.cpp:5:5: note: candidate: ‘A::A(const std::vector<std::basic_string<char> >&)’ 5 | A(std::vector<std::string> const& file_path) {} | ^ test.cpp:4:5: note: candidate: ‘A::A(const string&)’ 4 | A(std::string const& file_path) {} | ^ test.cpp:12:20: error: call of overloaded ‘A(<brace-enclosed initializer list>)’ is ambiguous 12 | A a2 = A({x, y}); | ^ test.cpp:5:5: note: candidate: ‘A::A(const std::vector<std::basic_string<char> >&)’ 5 | A(std::vector<std::string> const& file_path) {} | ^ test.cpp:4:5: note: candidate: ‘A::A(const string&)’ 4 | A(std::string const& file_path) {} | ^ And here is my current version information: (test_gcc) vyasr-dt% g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) Here is an example using the Compiler Explorer showing that this issue is specific to libstdc++ and the old ABI flag: https://godbolt.org/z/jqoc6j3be. For instance, with clang the error appears unless `-stdlib=libc++` is specified, at which point the code compiles successfully.