typeinfo *^%*&^%*&%

Alexandre Oliva oliva@dcc.unicamp.br
Thu Jun 11 17:38:00 GMT 1998


David Chamont <chamont@polhp3.in2p3.fr> writes:

> The following program is surprisingly displaying "i" and "1A" :

What is surprising about it?

>     cout<<typeid(int).name()<<endl ;
>     cout<<typeid(A).name()<<endl ;

The result of typeinfo::name() is implementation-defined, don't expect
to get the same result when you use different compilers, or different
versions of the same compiler.  G++ and egcs have chosen to return the
string produced by its own symbol name mangling mechanism.  `i' refers
to the integer type, and `1A' refer to a class name of length `1',
namely, `A'.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc-bugs mailing list