[Issue 24051] New: Safety attrib inference of enum/immut/const decls inconsistent with mutable static variable decls
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 19 19:19:06 UTC 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 at puremagic.com
Reporter: b2.temp at 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.
--
More information about the Digitalmars-d-bugs
mailing list