public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46206] New: using typedef-name error with typedef name hiding struct name
@ 2010-10-28  1:58 nathan.keynes at oracle dot com
  2010-10-28  2:16 ` [Bug c++/46206] " paolo.carlini at oracle dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: nathan.keynes at oracle dot com @ 2010-10-28  1:58 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-07-08 15:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-28  1:58 [Bug c++/46206] New: using typedef-name error with typedef name hiding struct name nathan.keynes at oracle dot com
2010-10-28  2:16 ` [Bug c++/46206] " paolo.carlini at oracle dot com
2013-08-05 10:59 ` paolo.carlini at oracle dot com
2013-08-05 13:47 ` paolo.carlini at oracle dot com
2013-08-05 19:00 ` paolo.carlini at oracle dot com
2013-08-07 10:11 ` paolo.carlini at oracle dot com
2013-08-09 12:05 ` paolo.carlini at oracle dot com
2014-04-22 11:36 ` jakub at gcc dot gnu.org
2014-07-16 13:28 ` jakub at gcc dot gnu.org
2014-10-30 10:39 ` jakub at gcc dot gnu.org
2015-06-26 20:01 ` jakub at gcc dot gnu.org
2015-06-26 20:30 ` jakub at gcc dot gnu.org
2020-07-08 15:59 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).