Thread overview
[Issue 23715] compilable/testcstuff1.c:273:23: error: function-scope 'tli' implicitly auto and declared '_Thread_local'
Feb 15, 2023
Iain Buclaw
Feb 20, 2023
Walter Bright
Feb 20, 2023
Iain Buclaw
[Issue 23715] ImportC: No rejection of _Thread_local variables declared at function scope without "static" as per C11 6.2.4-5
Feb 20, 2023
Iain Buclaw
Feb 27, 2023
Iain Buclaw
[Issue 23715] ImportC: No rejection of _Thread_local variables declared at function scope without 'static' as per C11 6.2.4-5
Apr 10, 2023
Walter Bright
Apr 10, 2023
Dlang Bot
Apr 10, 2023
Dlang Bot
February 15, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, ImportC
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=23689
         Depends on|                            |23689


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=23689
[Issue 23689] ImportC: C tests in the testsuite are not valid C
--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Shouldn't _Thread_local override the auto default?

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--- Comment #2 from Iain Buclaw <ibuclaw@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`.

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|compilable/testcstuff1.c:27 |ImportC: No rejection of
                   |3:23: error: function-scope |_Thread_local variables
                   |'tli' implicitly auto and   |declared at function scope
                   |declared '_Thread_local'    |without "static" as per C11
                   |                            |6.2.4-5

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
April 10, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ImportC: No rejection of    |ImportC: No rejection of
                   |_Thread_local variables     |_Thread_local variables
                   |declared at function scope  |declared at function scope
                   |without "static" as per C11 |without 'static' as per C11
                   |6.2.4-5                     |6.2.4-5

--
April 10, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15094 "fix Issue 23715 - ImportC: No rejection of _Thread_local variables de…" fixing this issue:

- fix Issue 23715 - ImportC: No rejection of _Thread_local variables declared at function scope without 'static' as per C11 6.2.4-5

https://github.com/dlang/dmd/pull/15094

--
April 10, 2023
https://issues.dlang.org/show_bug.cgi?id=23715

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15094 "fix Issue 23715 - ImportC: No rejection of _Thread_local variables de…" was merged into master:

- 281407b919869f1b7184b8f645fb55bdae8af4c7 by Walter Bright:
  fix Issue 23715 - ImportC: No rejection of _Thread_local variables declared
at function scope without 'static' as per C11 6.2.4-5

https://github.com/dlang/dmd/pull/15094

--
December 15, 2023
https://issues.dlang.org/show_bug.cgi?id=23715
Issue 23715 depends on issue 23689, which changed state.

Issue 23689 Summary: ImportC: C tests in the testsuite are not valid C https://issues.dlang.org/show_bug.cgi?id=23689

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--