public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "danregister at poczta dot fm" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65906] New: using-declaration allowed for non-direct base class
Date: Mon, 27 Apr 2015 14:32:00 -0000	[thread overview]
Message-ID: <bug-65906-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2015-04-27 14:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 14:32 danregister at poczta dot fm [this message]
2015-04-27 14:37 ` [Bug c++/65906] " danregister at poczta dot fm
2015-04-27 17:32 ` redi at gcc dot gnu.org
2021-07-27 21:30 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65906-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).