[Bug c++/59033] New: cannot control inherited constructors visibility

akim.demaille at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 6 21:09:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59033

            Bug ID: 59033
           Summary: cannot control inherited constructors visibility
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akim.demaille at gmail dot com

Hi,

Again, I have found no clear wording in the draft of the standard that I have,
however, consistency in the language would expect that "using" to import
constructors should provide them with the _current_ public/protected/private
visibility, not the one of the original constructor.

The following example shows that the "using" on types and "using" on
constructors are not treated the same way.

akim@padam /tmp $ cat foo.cc
struct base
{
protected:
  using type = int;
  base(type, type) {}
};

struct derived: public base
{
public:
  using base::base;
  using base::type;
};

int main()
{
  derived::type i;
  derived b(i,i);
}
akim@padam /tmp $ g++-mp-4.9 -Wall -std=c++11 foo.cc
foo.cc: In function 'int main()':
foo.cc:11:15: error: 'derived::derived(base::type, base::type)' is protected
   using base::base;
               ^
foo.cc:18:16: error: within this context
   derived b(i,i);
                ^
akim@padam /tmp $ g++-mp-4.9 --version
g++-mp-4.9 (MacPorts gcc49 4.9-20130915_0) 4.9.0 20130915 (experimental)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Same with 4.8.



More information about the Gcc-bugs mailing list