Alexander Terekhov wrote:
> Peter Dimov wrote:
>>
>> Ken Hagan wrote:
>>> Peter Dimov wrote:
>>>>
>>>> &k does not exist yet at compile-time (in a pointer to int form),
>>>> when templates are instantiated.
>>>
>>> It doesn't have to. We're instantiating a template, not calling a
>>> function, so if "&k" has the type "pointer to thread-local int" then
>>> the compiler knows that and can instantiate the appropriate code.
>
> Please define "appropriate code". Please see the added 2 lines below.

[...]

>> template<uintptr_t * p> struct C
>> {
>>     void f()
>>     {
>>         std::cout << " p: " << p << ": " << *p << std::endl;
>           static const uintptr_t * P = p;
>           std::cout << " P: " << P << ": " << *P << std::endl;
>>     }
>> };

Output:

 p: 00143204: 2024
 P: 00143204: 2024
&k: 00143204: 2024
 p: 00143224: 2036
 P: 00143204: 2024
&k: 00143224: 2036
 p: 00143244: 2012
 P: 00143204: 2024
&k: 00143244: 2012

I must admit that I didn't expect even for p to be different across threads.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to