public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99160] New: A wrong accessible check when using a using-declaration that introduces the names of type and function
@ 2021-02-19  9:56 xmh970252187 at gmail dot com
  2021-08-12 21:40 ` [Bug c++/99160] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: xmh970252187 at gmail dot com @ 2021-02-19  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99160
           Summary: A wrong accessible check when using a
                    using-declaration that introduces the names of type
                    and function
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

````cpp
#include <iostream>
struct A{
    struct C{
        using type = int;
    };
    void C(){}  //#1 if comment out this function definition, GCC will compile 
                //   this  example  
};
struct B:private A{
    using A::C;
};
int main(){
    B::C::type c;  //#2
}
````
For this example, GCC will report an error, which says "'struct A::C' is
inaccessible within this context". The result of this example is
https://godbolt.org/z/ddfrPM. If we comment out `void C(){}`, GCC will compile
the example.  

According to [namespace.udecl]#19. 
> A synonym created by a using-declaration has the usual accessibility for a member-declaration.   

That means the name `C` is accessible in the  nested-name-specifier at #2(the
name would be found in the scope of `B` in which the using-declaration will
create the synonym name for that name, the created name has the same
accessibility as the member-declaration)

Clang can compile this example even if we do not comment out the function
definition at #1

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

end of thread, other threads:[~2021-08-17  7:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19  9:56 [Bug c++/99160] New: A wrong accessible check when using a using-declaration that introduces the names of type and function xmh970252187 at gmail dot com
2021-08-12 21:40 ` [Bug c++/99160] " pinskia at gcc dot gnu.org
2021-08-16 10:06 ` redi at gcc dot gnu.org
2021-08-16 10:07 ` redi at gcc dot gnu.org
2021-08-17  1:49 ` xmh970252187 at gmail dot com
2021-08-17  6:46 ` redi at gcc dot gnu.org
2021-08-17  7:00 ` xmh970252187 at gmail dot com

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