C++ typedefs

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Sun Feb 22 02:49:00 GMT 1998


I find that egcs rejects

void X(){}
typedef int X;

as invalid C++ (redeclared as different kind of symbol). I cannot find
the place in the draft where it says that this is ill-formed. Instead,
typedefs are explained as declaring new types in [decl.typedef]. In
turn, it should be possible to have a typedef with the same name as a
function, whereas

class X{};
typedef int X;

should be incorrect (and is detected as such).

So, my interpretation would be that above program is correct, and
that the function shadows the typedef. Comments?

Martin



More information about the Gcc-bugs mailing list