[cxx-abi-dev] Mangling of named constants

John H. Spicer jhs at edg.com
Thu Oct 17 02:13:34 UTC 2002


Mark Mitchell wrote:

>I've been asked to get clarification here about the following issue.
>
>Given:
>
>  extern const int N = 3;
>
>  template <int I> struct S{};
>
>  template <int I> void f(S<N>) {}
>
>  template void f<7>(S<N>);
>
>how is instantiation to be mangled?  With "N" or with "3" as the
>template argument to "S"?
>
>The ISO C++ standard doesn't make us choose, as far as I can tell, in
>that it deliberately leaves unspecified whether these two templates
>are the same:
>
>  template <int I> void f(S<3>);
>  template <int I> void f(S<N>);
>
>(If N has internal linkage, does that change anything?)
>

I don't think this is quite the right example.  The special rules for 
template equivalence apply only to expressions that involve template 
parameters.  So, if the expression was "3+I" or "N+I", the
rules would apply.   f(S<some_way_to_name_3>) and 
f(S<other_way_to_name_3>) must mangle to the same thing, which I think 
means you have to use the actual integer value.

The fact that N has internal linkage is not important.

John.





More information about the cxx-abi-dev mailing list