[Issue 24867] Wrong deprecation warning of @system variable usage under CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 19 20:16:12 UTC 2024


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

--- Comment #8 from Luís Ferreira <contact at lsferreira.net> ---
> Sure you can specify the alignment when you define the constant, but this is here to prevent forgetting and then having issues. 

Also, one more point on this: it doesn't matter where you put it if you, in the
end, align it the same way, but the @system issue doesn't trigger on this
situation:

```
struct Bar {
        align(1): 
    const char* name;
    int b = 2;
}

struct Foo {
    static immutable align(1) Bar bar = Bar("foo");

    @safe
    void foo()
    {
        static assert(bar.b == 2);
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list