[PATCH] PR libstdc++/13045 / C++ demangler, floating values and function pointer type return type postfix fix.
Gabriel Dos Reis
gdr@integrable-solutions.net
Wed Nov 26 05:42:00 GMT 2003
Ian Lance Taylor <ian@wasabisystems.com> writes:
| Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
|
| > It will not work. One reason was explained by DJ. Another is that
| > it does not reduce to a normal form before outputing leading to many
| > symbols being thought different while they are the same.
|
| Note that g++ already does not reduce to normal form.
|
| If it did, we would not have this problem, as all floating point
| literals could be eliminated, since g++ does not permit floating point
| values as template arguments.
|
| For example, given this input:
|
| template<int v> struct A { static const int i = v; A(int); };
| template<int i> void f(A<i+0>, A<0+i>) {}
| void g() { f<1>(1, 2); }
|
| The name of f<1> is
| void f<1>(A<(1) + (0)>, A<(0) + (1)>)
| In other words, g++ does not recognize that A<i+0> and A<0+i> are
| arguably the same type, at least in the sense that it is probably
| impossible to distinguish between them other than by different
| instantiations of static variables.
|
| Is this a bug in g++?
As Mark and Matt explained the issue to me recently at Kona, the
"i + 0" and "0 + i" kept in non-normal forms are an engineering
solution for a general problem the ABI committee thought hard.
The general problem comes from an obscure section in the "template
chapter" (14.5.5.1/7) that says that
If a program contains declarations of function templates that are
functionally equivalent but not equivalent, the program is
ill-formed; no diagnostic is required.
But, you're on the right track in pointing out that it is the presence
of those non-normal forms that are causing the troubles we're having now.
And that puzzles many C++ programmers, even the advanced ones.
And I do not believe it is sensible to multiply those problems by any
factor, which is why I'm maintaining that floating point literals
should be reduced in normal form before being used as part of mangled
names.
-- Gaby
More information about the Libstdc++
mailing list