What is the formal way of defining a _Thread_local identifier association?

This is a legal language question in relation to the angle in the C11 standard.

The rules governing the relationship of an identifier in a C program are set out in clause 6.2.2 of standard C11. In particular, in 6.2.2 (5) it is stated that (my attention):

If the identifier declaration for a function does not have a storage class specifier, its binding is defined exactly as if it were declared using the storage class specifier extern. If an identifier declaration for an object has a file scope and not a storage class specifier , its relationship is external.

In the case of an announcement, such as _Thread_local int a;in the file area, 6.2.2 (5) above does not apply, because it _Thread_local is a storage specifier. None of the other provisions of 6.2.2 applies, or (no statictherefore (3) does not apply, and not in the block area, is an object, not a parameter, therefore (6) is not applicable, etc.). And what should the connection acomply with the Standard? Did I miss some other rules that define communication in this case?

I understand that the intention is to make him have an external connection (how does gcc view this case), but how does it follow from the Standard itself?

Note that it’s normal that there is an announcement like static _Thread_local int a; extern _Thread_local int a;, and in this case, rules 6.2.2 apply only to the fine when it ahas an internal binding (despite the fact that extern).

Finally, semantics _Thread_localare irrelevant here.

+4
source share
1 answer

, C11 6.2.4p4 _Thread_local main(), {} main(), auto, , , main(), . , , , , _Thread_local, , " " , 6.7.1p2.

0

Source: https://habr.com/ru/post/1692823/


All Articles