This is the mail archive of the gcc-bugs@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]

[Bug c++/46206] New: using typedef-name error with typedef name hiding struct name


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46206

           Summary: using typedef-name error with typedef name hiding
                    struct name
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nathan.keynes@oracle.com


G++ rejects the following code:

class Foo
{
    bool a, b, c, d;
    typedef struct Bar { } Bar;
    virtual void foo(void) {
        struct Bar bar;
    }
};

example.cc: In member function âvirtual void Foo::foo()â:
example.cc:6: error: using typedef-name âFoo::Barâ after âstructâ
example.cc:4: error: âFoo::Barâ has a previous declaration here
example.cc:6: error: invalid type in declaration before â;â token

but accepts many similar examples, including:
class Foo
{
    bool a, b, c;
    typedef struct Bar { } Bar;
    virtual void foo(void) {
        struct Bar bar;
    }
};

This behaviour is reproducible on x86_64-redhat-linux (4.1.2 and 4.4.0) and
i386-pc-solaris2.11 (4.2.4, 4.3.4 and 4.5.1)

I'm uncertain if this is strictly legal or not per the standard, but it doesn't
seem to make sense to accept one of these cases but not the other.


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