https://issues.dlang.org/show_bug.cgi?id=23715

Iain Buclaw <ibuc...@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuc...@gdcproject.org

--- Comment #2 from Iain Buclaw <ibuc...@gdcproject.org> ---
(In reply to Walter Bright from comment #1)
> Shouldn't _Thread_local override the auto default?
It does not, and the C11 spec makes this clear:

This paragraph under C11 6.2.4 - Storage durations of objects

"""
C11 6.2.4-5:
An object whose identifier is declared with no linkage and without the
storage-class specifier `static` has *automatic storage duration*, as do some
compound literals. The result of attempting to indirectly access an object with
automatic storage duration from a thread other than the one with which the
object is associated is implementation-defined.
"""

So, top-level `_Thread_local` variables of course get either external or
internal linkage (depending on `static`).  Local variables *always* have no
linkage unless declared `static`.

The correct test (that is also accepted by gcc/clang) would be:
```
void test2()
{
    static _Thread_local int tli;
}
```

ImportC parser still needs fixing to reject invalid uses of `_Thread_local`.

--

Reply via email to