https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932
--- Comment #14 from Xi Ruoyao <ryxi at stu dot xidian.edu.cn> ---
(In reply to Martin Sebor from comment #13)
> (In reply to Xi Ruoyao from comment #11)
>
> The target demangler is (or can be) different on each target and, as I said,
> different producers use different strings (for example, neither Clang nor
> IBM XLC++ includes the suffix, and Oracle CC on Linux uses the cast
> notation).
>
> The most natural representation of an integer in C++ (and in C) is a decimal
> literal with no suffix (unless its value doesn't fit in the signed integer
> with the greatest precision).
>
> So my opinion that you asked for is that insisting on anything else is an
> inferior choice. If you don't share it please do no feel compelled to
> convince me of yours.
See below:
a.cc:
~~~~~
template <int x> struct a {int foo() {return -x;}};
template struct a<1>;
~~~~~
and b.cc:
~~~~~
template <unsigned x> struct a {int foo();};
int main() {return a<1>().foo();}
~~~~~
This error happens when a library's ABI changes, and someone tries to link old
object code to the new library. With libiberty's demangle (in GNU ld), we have
error message:
/tmp/ccKFWvhT.o: In function `main':
b.cc:(.text+0x10): undefined reference to `a<1u>::foo()'
collect2: error: ld returned 1 exit status
But what would we get with "natural" expression?
b.cc:(.text+0x10): undefined reference to `a<1>::foo()'
It's hard to know what happened. We have two different mangled name with the
same demangled name. It's strange and could be a new example in "How not to
programming in C++".