"H.J. Lu" <hjl.to...@gmail.com> writes: >>> "_ZZN1N1fEiEs": encoding of N::f::"Itanium C++ ABI" (no discriminator) >> >> The discriminator is optional and is up to the discretion of the >> compiler. This doesn't matter for interoperability purposes, because >> such names can not be referenced from other translation units anyhow. > > If it isn't optional, tools can't depend on it. I was wondering > how useful it was.
Consider namespace N { inline char f(int i) { char a, b; { static const char *p = "Itanium C++ ABI"; // p = 1, "..." = 2 a = p[i]; } { static const char *p = "My ABI"; // p = 1, "..." = 2 b = p[i]; } return a + b; } char foo (int i) { return f (i); } } There are two local variables named 'p' in the same function. You need the discriminator to discriminate between them. That doesn't meant that the ABI needs to prescribe the exact value which should be used for the discriminator. > Another issue for scope encoding. C++ ABI: > > --- > Occasionally entities in local scopes must be mangled too > (e.g. because inlining or template compilation causes multiple > translation units to require access to that entity). > --- > > seems to imply that the local symbols may have external > linkage. Am I wrong? You are wrong. When an inline function is expanded into multiple translation units, and that inline function has a static variable, then multiple translation units require access to the static variable. That does not imply that the static variable has external linkage. >> What do you think the symbol name should be? >> > > Isn't it specified in C++ ABI? No. The C++ ABI does not precisely specify the name mangling to use for symbols which can not be referenced from other translation units. Ian