Bug 23313 – Accessing TLS is apparently fine from shared context

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-08-29T16:36:02Z
Last change time
2024-12-13T19:24:18Z
Assigned to
No Owner
Creator
Sebastiaan Koppe
Moved to GitHub: dmd#20142 →

Comments

Comment #0 by mail — 2022-08-29T16:36:02Z
dg1 fails because `i` is not shared. You would expect dg2 to fail as well. Somehow because `j` is an TLS variable however, it is suddenly fine. ``` void main() @safe { int i = 1; static int j = 2; auto dg1 = () shared @safe => i; // error auto dg2 = () shared @safe => j; // no error?? } ```
Comment #1 by dfj1esp02 — 2022-08-30T15:16:00Z
The shared attribute on the delegate applies to captured closure variables. TLS isn't part of closure context, in a way it's stored in the thread, not in the closure. Normal shared methods can access TLS just fine too.
Comment #2 by robert.schadek — 2024-12-13T19:24:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20142 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB