https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054

            Bug ID: 67054
           Summary: Constructor inheritance with non-default constructible
                    members
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alltaken380 at gmail dot com
  Target Milestone: ---

Created attachment 36086
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36086&action=edit
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)

Reply via email to