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

            Bug ID: 87518
           Summary: namespace and typedef : scope problem
           Product: gcc
           Version: 8.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pierreblavy at yahoo dot fr
  Target Milestone: ---

Created attachment 44784
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44784&action=edit
test code

Hello.

The following c++ code compiles with 'clang++ -std=c++17 test.cpp' but not with
 'g++ -std=c++17 test.cpp'

I don't know who's right between clang and gcc, but I suspect that gcc reads
the 'typedef t t' line backward, and therefore override the first 't' with the
second one.

This bug might be related to bug number 23594

Best regards


--- test.cpp ---
namespace test{
   typedef double t;

   struct A{
     typedef t t;
   };
}

int main(int,char**){return 0;}



--- g++ error message ---
g++ -std=c++17 test.cpp 
test.cpp:5:16: error: declaration of ‘typedef test::t test::A::t’
[-fpermissive]
      typedef t t;
                ^
test.cpp:2:19: error: changes meaning of ‘t’ from ‘typedef double test::t’
[-fpermissive]
    typedef double t;



--- g++ --version ---
g++ (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)

Reply via email to