[cxx-abi-dev] Mangling of named constants

Mark Mitchell mark at codesourcery.com
Thu Oct 17 05:28:05 UTC 2002



--On Wednesday, October 16, 2002 10:13:34 PM -0400 "John H. Spicer" 
<jhs at edg.com> wrote:

> 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.

Ah, good point.  OK; let's consider the example as if I had written
"I + N" everywhere I wrote "N".

Thanks,

-- 
Mark Mitchell                mark at codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the cxx-abi-dev mailing list