Created attachment 36086 [details] Preprocessed source code Following code won't compile: struct NonDefault { NonDefault(int) {} }; struct Base { Base(int) {} }; struct Derived : public Base { NonDefault foo = 4; using Base::Base; }; auto test() { auto d = Derived{ 5 }; } $ g++ -std=c++14 -c test.cpp test.cpp: In function ‘auto test()’: test.cpp:20:25: error: use of deleted function ‘Derived::Derived(int)’ auto d = Derived{ 5 }; ^ test.cpp:15:17: note: ‘Derived::Derived(int)’ is implicitly deleted because the default definition would be ill-formed: using Base::Base; ^ test.cpp:15:17: error: no matching function for call to ‘NonDefault::NonDefault()’ test.cpp:3:5: note: candidate: NonDefault::NonDefault(int) NonDefault(int) {} ^ test.cpp:3:5: note: candidate expects 1 argument, 0 provided test.cpp:1:8: note: candidate: constexpr NonDefault::NonDefault(const NonDefault&) struct NonDefault ^ test.cpp:1:8: note: candidate expects 1 argument, 0 provided test.cpp:1:8: note: candidate: constexpr NonDefault::NonDefault(NonDefault&&) test.cpp:1:8: note: candidate expects 1 argument, 0 provided $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc-multilib/src/gcc-5.2.0/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible Thread model: posix gcc version 5.2.0 (GCC)
Confirmed. (The testcase is valid C++11 too, except for the unnecessary auto return type.)
I stumbled across this bug, too (and asked about it on stackoverflow, since I wasn't sure if it's valid C++11, see http://stackoverflow.com/questions/40932844/constructor-inheritance-and-direct-member-initialisation). This problem is still there in gcc 6.2.0. The code compiles, if one adds a default constructor to NonDefault, despite that default constructor never gets called in the end. (This can be used as a work-around).
Still occurs in 4.8 to 7.1, according to this duplicate https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80851 Also, could we perhaps get a more useful title for this one? It describes what is involved in the problem, but not what the problem is.
(In reply to DB from comment #3) > Still occurs in 4.8 to 7.1, according to this duplicate > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80851 > > Also, could we perhaps get a more useful title for this one? It describes > what is involved in the problem, but not what the problem is. What title do you suggest?
Author: jason Date: Wed Jul 26 17:39:26 2017 New Revision: 250583 URL: https://gcc.gnu.org/viewcvs?rev=250583&root=gcc&view=rev Log: PR c++/67054 - Inherited ctor with non-default-constructible members * method.c (walk_field_subobs) Consider member initializers (NSDMIs) when deducing an inheriting constructor. Added: trunk/gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/method.c
Author: jason Date: Wed Aug 9 20:17:47 2017 New Revision: 251000 URL: https://gcc.gnu.org/viewcvs?rev=251000&root=gcc&view=rev Log: PR c++/67054 - Inherited ctor with non-default-constructible members * method.c (walk_field_subobs) Consider member initializers (NSDMIs) when deducing an inheriting constructor. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/method.c
Author: aldyh Date: Wed Sep 13 15:47:25 2017 New Revision: 252096 URL: https://gcc.gnu.org/viewcvs?rev=252096&root=gcc&view=rev Log: PR c++/67054 - Inherited ctor with non-default-constructible members * method.c (walk_field_subobs) Consider member initializers (NSDMIs) when deducing an inheriting constructor. Added: branches/range-gen2/gcc/testsuite/g++.dg/cpp0x/inh-ctor29.C Modified: branches/range-gen2/gcc/cp/ChangeLog branches/range-gen2/gcc/cp/method.c
Fixed in 7.2.
(In reply to Leonid Koppel from comment #8) > Fixed in 7.2. Indeed, thanks.
*** Bug 80851 has been marked as a duplicate of this bug. ***