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

Re: [c++] Another question about demangler output


Daniel Jacobowitz <drow@mvista.com> writes:

>> | > if you use typeof to represent int (*)() in the demangled symbol, do
>> | > you offer a way to distinguish it from the template instantiation with
>> | > T = int (which is a  different function)?
>> | 
>> | Currently, an instantiation of the latter for T = double looks like:
>> |   foo::operator double (*)()<double>()
>> 
>> Ah, I see.  That isn't valid C++ either :-)
>> (Besides the 'double (*)()' thingy that started this thread, there is
>> no way to specify an explicit template argument for a conversion
>> function, so the <double> annotation isn't valid either).  Fun, fun.
>
> Right.  Is there a valid way in C++ to represent the difference between
> these?
>
> Otherwise it's yet another example of the demangler being compelled to
> print out invalid C++, which is making everything quite gross.

I am getting the impression that typedef and template constructs can
produce classes of mangled names that simply cannot be represented by
single expressions in conforming C++.

If this is the case, then the alternatives would seem to be either
printing out demangled expressions that are invalid C++ but
comprehensible to a human, or else making up names as necessary and
printing their definitions too.  The latter seems like too much
trouble, and liable to confuse humans more than the former.

I'd also like to point out that the 'typeof' extension operator would
not be doing its job if it ever appeared in a mangled name.  For a
simple example, given

 template <class T> T foo (T x) { ... }
 int bar;

all three of these:

 bar = foo(bar);
 bar = foo<int>(bar);
 bar = foo<typeof(bar)>(bar);

must cause the instantiation of _Z3fooIiET_S0_, not any more
complicated name.

(Hoom, one is not pleased that the abbreviation mechanism has made the
identifier longer in this instance.  _Z3fooIiEii would be optimal.)

zw


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