Ulf Magnusson wrote:
On Wed, Nov 14, 2012 at 6:10 PM, Piotr Wyderski
<piotr.wyder...@gmail.com>  wrote:
The following snippet:

class A {};
class B : public A {

    typedef A super;

public:

    class X {};
};


class C : public B {

    typedef B super;

    class X : public super::X {

       typedef super::X super;
    };
};

compiles without a warning on Comeau and MSVC, but GCC (4.6.1 and
4.7.1) failes with the following message:

$ gcc -c bug.cpp
bug.cpp:18:24: error: declaration of ‘typedef class B::X C::X::super’
[-fpermissive]
bug.cpp:14:14: error: changes meaning of ‘super’ from ‘typedef class B
C::super’ [-fpermissive]

Should I file a report?

     Best regards, Piotr
Here's a two-line TC:

typedef struct { typedef int type; } s1;
struct S2 { s1::type s1; };

Fails with GCC 4.6.3; succeeds with clang 3.0. Looks like a bug to me.

/Ulf

In your example, GCC is in fact right. Basically, you mustn't have a name refer 
to two things in a class:

3.3.6/1: ... 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. No diagnostic is required for a violation of this rule. 
...

Regards
Jiří Paleček


Reply via email to