This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/65291] protected using constructor default arguments not recognized


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Do you really need to attach a tarball with four separate files to demonstrate
this?! It just makes it a pain to inspect the code.

Here's the complete source:

class A {
 public:
  A(int a = 0) { }
};

class B : public A {
 public:
  B(int b1, int b2) : A(b1) {}
 protected:
  using A::A;
};

class C : public B {
 C() : B() {}
};
int main() {
 B b(1,2);
 C c;
}

The C++ standard says that B inherits a constructor taking a single int, the
default argument is not inherited, so B has no default constructor, and G++ is
correct to reject the program.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]