Name mangling

Martin von Loewis loewis at informatik.hu-berlin.de
Tue Oct 19 07:27:42 UTC 1999


> Entities with no linkable name, but which need to be referenced  
> accross translation units (inlining, template instantiations):
> 
> 1. String constants
> 2. Static local variables
> 

I can see the usage of these being referenceable for
inlining. However, I don't think that such a feature is mandated by
the C++ standard, at least for string literals.

In particular, string literals may not appear as template parameters
(see http://www.informatik.hu-berlin.de/~loewis/corer8.html#100 for a
ready issue), and neither can static local variables
([temp.arg.nontype]/1).

The only case were the ABI needs to define something is static local
variables in inline functions:

inline void foo()
{
  static Bar object(42);
}

In this case, I believe you need *two* well-known assembler symbols:
one for the name of foo::object, and one for the flag whether
foo::object has been initialized. Of course, that would also require
to define specific values for the flag.

> Note that to enable a "compiler-driven" inlining, these need to be  
> named inside any function, not only inline ones.

Does this need to be part of the ABI? I.e. is there any chance that
such compiler-driven inlining is works across compilers?

> For variable size, we may have a problem with array sizes. What  
> about linking:
> 
> foo.C:	extern int a[10];
> bar.C:	int a[200000];
> 
> Problem: short data space. the declaration in foo.C may seem like a  
> good 'short' candidate, whereas the definition is not.

Isn't this ill-formed? AFAIK, it would be ok if you get a linker
error. Alternatively, it would be ok if it links fine and later
crashes.

Regards,
Martin





More information about the cxx-abi-dev mailing list