July 19, 2023
https://issues.dlang.org/show_bug.cgi?id=24051

          Issue ID: 24051
           Summary: Safety attrib inference of enum/immut/const decls
                    inconsistent with mutable static variable decls
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: b2.temp@gmx.com

this code is accepted without deprecation

```d
enum uint* ptr = cast(uint*)0xC00000; // same with const/immut instead of enum
void main() @safe {
    import core.volatile : volatileStore;
    volatileStore(ptr, 8);
}
```

But

```
uint* ptr = cast(uint*)0xC00000;
void main() @safe {
    import core.volatile : volatileStore;
    volatileStore(ptr, 8);
}
```

with -de, is rejected with

> Deprecation: cannot access `@system` variable `ptr` in @safe code

Maybe there should be a deprecation message in all the cases.

--