[Issue 24425] New: @standalone attribute should be usable on thread-local static constructors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 1 03:29:11 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24425
Issue ID: 24425
Summary: @standalone attribute should be usable on thread-local
static constructors
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
This is a valid use of standalone constructors and should be allowed:
```d
import core.attribute;
int *foo;
@standlone @system static this() {
foo = new int(10);
}
```
Yet, the compiler doesn't allow this usage.
I'm unsure whether the compiler needs to do anything fancy here. There is an
`MIstandalone` flag, which means all shared *and* thread-local static ctors of
a module are standalone. And there is also an `ictor` function pointer which
appears to be independent construction for a module. I'm not sure how each is
used, but I would imagine constructing a "dummy" moduleinfo that contains only
standalone ctors/dtors (by using the MIstandalone flag) is possible whenever
needed.
I know that druntime already would handle this case properly.
--
More information about the Digitalmars-d-bugs
mailing list