5

It says in C++ 3.3.7.2 [basic.scope.class]

A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S.

What is an example of a translation unit where a name N used in a class S refers to a different declaration in its context than when it is re-evaluated in the completed scope of S?

Yuushi
  • 25,132
  • 7
  • 63
  • 81
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
  • possible duplicate of [typedef changes meaning](http://stackoverflow.com/questions/12187549/typedef-changes-meaning) – Tony Delroy May 09 '13 at 01:50

1 Answers1

1
struct X {};
struct Y {};

typedef X N;

struct S
{
    N n;
    typedef Y N;
};

$ g++ test.cpp 
9:15: error: declaration of ‘typedef struct Y S::N’ [-fpermissive]
4:11: error: changes meaning of ‘N’ from ‘typedef struct X N’ [-fpermissive]
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319