public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Errors using the same identifier as type and function name
@ 2008-09-01 23:59 Rodolfo Lima
  2008-09-02  1:00 ` John Fine
  0 siblings, 1 reply; 4+ messages in thread
From: Rodolfo Lima @ 2008-09-01 23:59 UTC (permalink / raw)
  To: gcc-help

Hi, I wonder why the following code gives the error below with
gcc-3.4.6 up to 4.3.1 (I don't know about earlier versions):

struct type {};

struct A
{
     type *type() { return 0; }
};

teste.cpp:5: error: declaration of 'type* A::type()'
teste.cpp:1: error: changes meaning of 'type' from 'struct type'

If we define 'A' as

struct A : type
{
     type *type() { return 0; }
};

it compiles fine.

I've searched the C++2003 standard for something related to this but 
couldn't find anything. Anyone knows what's happening here?

IMHO it should compile because 'A::type' is in a different scope of 
'struct type', and the fact that we're referencing 'struct type' 
*before* specifying 'A::type' function name shouldn't make both 
identifiers ambiguous.

Regards,
Rodolfo Lima

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

end of thread, other threads:[~2008-09-02 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-01 23:59 Errors using the same identifier as type and function name Rodolfo Lima
2008-09-02  1:00 ` John Fine
2008-09-02  1:12   ` Rodolfo Lima
2008-09-02 12:11     ` Marco Manfredini

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).