public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public
       [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
@ 2015-01-15 18:03 ` petschy at gmail dot com
  2021-07-31 21:22 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: petschy at gmail dot com @ 2015-01-15 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from petschy at gmail dot com ---
Created attachment 34457
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34457&action=edit
complete test case


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public
       [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
  2015-01-15 18:03 ` [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public petschy at gmail dot com
@ 2021-07-31 21:22 ` pinskia at gcc dot gnu.org
  2021-07-31 21:23 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-31 21:22 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |UNCONFIRMED
     Ever confirmed|1                           |0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public
       [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
  2015-01-15 18:03 ` [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public petschy at gmail dot com
  2021-07-31 21:22 ` pinskia at gcc dot gnu.org
@ 2021-07-31 21:23 ` pinskia at gcc dot gnu.org
  2021-08-02 14:13 ` redi at gcc dot gnu.org
  2021-08-04  9:31 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-31 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang rejects this code with a similar error message as gcc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public
       [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-07-31 21:23 ` pinskia at gcc dot gnu.org
@ 2021-08-02 14:13 ` redi at gcc dot gnu.org
  2021-08-04  9:31 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-02 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The standard is clear that D::D(int) is protected:

"Base-class constructors considered because of a using-declarator are
accessible if they would be accessible when used to construct an object of the
base class; the accessibility of the using-declaration is ignored."

So G++ is correct to give an error on that line.

I'm not sure why D::D() is public though. It seems that it isn't inherited from
B::B() but is implicitly defined by the compiler (and then calls B::B() but
it's OK for D's constructor to call the protected constructor of its base
class).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public
       [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-08-02 14:13 ` redi at gcc dot gnu.org
@ 2021-08-04  9:31 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-04  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The standard says:

"If there is no user-declared constructor for class X, a non-explicit
constructor having no parameters is implicitly declared as defaulted"

An inherited constructor is not user-declared, so D still gets an
implicitly-declared:

  D() = default;

This is public, and can call the protected B() constructor.

So G++ is correct.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-04  9:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-64615-4@http.gcc.gnu.org/bugzilla/>
2015-01-15 18:03 ` [Bug c++/64615] Access level check error: g++ thinks the non default ctor is protected while its public petschy at gmail dot com
2021-07-31 21:22 ` pinskia at gcc dot gnu.org
2021-07-31 21:23 ` pinskia at gcc dot gnu.org
2021-08-02 14:13 ` redi at gcc dot gnu.org
2021-08-04  9:31 ` redi at gcc dot gnu.org

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).