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

            Bug ID: 65906
           Summary: using-declaration allowed for non-direct base class
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danregister at poczta dot fm
  Target Milestone: ---

GCC compiles without complaining the following code, which contains
using-declaration which brings constructor of non-direct base class:

----------------------------------------------------------------
#include <iostream>
void log(std::string msg) { std::cout << msg << std::endl; }

struct Base
{
        Base() { log(__func__); }
        Base(int, int) { log(__func__); }
};
struct D1 : Base
{
        D1() { log(__func__); }
};
struct D2 : D1
{
        D2() { log(__func__); }
        using Base::Base;
};

int main()
{
        D2 d(1, 2);
}
----------------------------------------------------------------

The output:

----------------------------------------------------------------
Base
D1
----------------------------------------------------------------

The same code compiled with clang produces: error: 'Base' is not a direct base
of 'D2', cannot inherit constructors

Possible duplicate: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32039

Reply via email to