Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #79138

Re: Injected class name

Subject Re: Injected class name
Newsgroups comp.lang.c++
References (1 earlier) <ie5v3oF8lk9U1@mid.individual.net> <s5ks9i$7mp$1@dont-email.me> <s5ntrb$nt0$1@dont-email.me> <s5nvhq$kjf$1@gioia.aioe.org> <s5p9bm$1ab$1@dont-email.me>
From Richard Damon <Richard@Damon-Family.org>
Message-ID <O8WfI.15065$1%.7010@fx37.iad> (permalink)
Organization Forte - www.forteinc.com
Date 2021-04-21 09:54 -0400

Show all headers | View raw


On 4/21/21 9:29 AM, Andrey Tarasevich wrote:
> On 4/20/2021 6:35 PM, Christian Hanné wrote:
>>>> ... or one can use an elaborated type specifier
>>>>   class C : B
>>>>   {
>>>>     class A *p;
>>>>   };
>>>> which apparently simply ignores access restrictions.
>>
>>> Scratch that. This appears to be a bug in GCC. Neither Clang nor MSVC
>>> allow that.
>>
>> No, that's perfectly legal code !
> 
> Sorry, but a mere "that's perfectly legal code" will not fly here with me.
> 
> If you claim that a private name `A` should be accessible here through
> elaborated type specifier `class A` (and that Clang and MSVC are wrong
> in rejecting this code), you need to explain in detail what makes you
> think so. You need to quote the C++ standard.
> 

I would need to dig hard through the standard to figure out which is
right, but the name A does get into class C by two different paths. One
is that it is a global name, the other is that it is a private base of a
base class.

A basic rule is accessibility does not affect visibility, so if the
visibility via base class has priority of the global visibility, it will
hide it without scoping, and then be not accessible.

Apparently there is a difference in how it was read by two compiler
writers, (or at least implemented) and a careful study would be needed
to see which is right.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-19 08:16 -0700
  Re: Injected class name Bo Persson <bo@bo-persson.se> - 2021-04-19 20:05 +0200
    Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-19 14:21 -0700
      Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-20 18:06 -0700
        Re: Injected class name Christian Hanné <the.hanne@gmail.com> - 2021-04-21 03:35 +0200
          Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-21 06:29 -0700
            Re: Injected class name Richard Damon <Richard@Damon-Family.org> - 2021-04-21 09:54 -0400
              Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-21 07:35 -0700
                Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-21 07:48 -0700
  Re: Injected class name Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-04-19 11:34 -0700
  Re: Injected class name "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-21 15:45 -0700

csiph-web