On Wed, Aug 7, 2013 at 11:51 AM, Paul Pluzhnikov <ppluzhni...@google.com> wrote:
>
> The following source:
>
>   template<typename T> static void f();
>   void g() { f<int>(); }
>
> results in "_Z1fIiEvv" under g++, but in "_ZL1fIiEvv" under clang.
>
> Richard Smith says:
>
>   The ABI doesn't cover manglings for local symbols ...
>   ... and c++filt is not able to cope with the L prefix here.
>
>   I'm having a hard time seeing how this isn't a g++ bug and a matching
>   c++filt bug.
>
> It's hard for me to argue that this is a 'g++' bug (since there is no
> ABI violation here), but c++filt should be able to handle this, and does
> with attached patch.

OK, I finally took a look.

The demangler treates _ZL as a local-source-name.  This is not part of
the C++ ABI (http://codesourcery.com/cxx-abi/).  It was added by Geoff
Keating: http://gcc.gnu.org/PR31775,
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00309.html .

With Geoff's patch the demangling is

_Z <encoding>
  <encoding> => <(data) name>
_Z <(data) name>
  <name> => <unscoped-name>
_Z <unscoped-name>
  <unscoped-name> => <unqualified-name>
_Z <unqualified-name>
  <unqualified-name> => <local-source-name> (not in ABI)
_Z <local-source-name>
  <local-source-name> => L <source-name> [<discriminator>] (not in ABI)
_ZL <source-name> [<discriminator>]
  <source-name> => <number> <identifier>
_ZL1f [<discriminator>]

The discriminator is not present, and at this point we are in trouble
because IiE is extraneous.

But really the demangling should be

_Z <encoding>
  <encoding> => <(data) name>
_Z <(data) name>
  <name> => <unscoped-template-name> <template-args>
_Z <unscoped-template-name> <template-args>
  <unscoped-template-name> => <unscoped-name>
_Z <unscoped-name> <template-args>
  <unscoped-name> => <unqualified-name>
_Z <unqualified-name> <template-args>
  <unqualified-name> => <local-source-name> (not in ABI)
_Z <local-source-name> <template-args>
  <local-source-name> => L <source-name> [<discriminator>] (not in ABI)
_ZL <source-name> [<discriminator>] <template-args>
  <source-name> => <number> <identifier>
_ZL1f [<discriminator>] <template-args>
  [<discriminator>] =>
_ZL1f <template-args>

etc.

So it looks to me like Geoff's original patch was wrong, and your
patch is correct.

So this is OK.

Thanks.

Sorry for ignoring this for so long.

Ian

Reply via email to