This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++] Possible GCC bug


Ulf Magnusson wrote:
On Wed, Nov 14, 2012 at 6:10 PM, Piotr Wyderski
<piotr.wyderski@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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]