This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77747] New: GCC allows inheriting constructors from indirect base
- From: "vasek.potocek at post dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 26 Sep 2016 17:02:50 +0000
- Subject: [Bug c++/77747] New: GCC allows inheriting constructors from indirect base
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77747
Bug ID: 77747
Summary: GCC allows inheriting constructors from indirect base
Product: gcc
Version: 6.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vasek.potocek at post dot cz
Target Milestone: ---
Created attachment 39690
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39690&action=edit
Minimal test case (preprocessed file)
According to the standard ([namespace.udecl] §3), it should only be possible to
inherit constructors from a direct base class. The following example shows a
good example why this is important:
class X {
public:
X() { std::cout << "Default" << std::endl; }
X(int a) { std::cout << a << std::endl; }
};
class Y : public X { };
class Z : public Y {
using X::X;
};
int main() {
Z instance{3}; // how is Y constructed?
}
G++ accepts this code even with strictest warning level settings with the
following result: Y is default-constructed, default-constructing X on its way,
and the parameter provided in the last line is silently ignored.
System version:
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC)
Command line:
g++ -Weffc++ -Wall -Wextra -pedantic -fno-diagnostics-show-caret -save-temps
skip.cpp -o skip
Compiler output: none