Bug 24316 – Allow CTFE access to immutable variable through pointer
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-01-02T18:10:29Z
Last change time
2024-01-02T22:09:08Z
Keywords
pull
Assigned to
No Owner
Creator
Tim
Comments
Comment #0 by tim.dlang — 2024-01-02T18:10:29Z
The following code currently does not compile:
```
struct S
{
int i;
}
int f(immutable S *s)
{
return s.i;
}
immutable S globalS = S(5);
static assert (f(&globalS) == 5);
```
DMD produces the following error:
Error: cannot dereference pointer to static variable `globalS` at compile time
Comment #1 by dlang-bot — 2024-01-02T18:19:18Z
@tim-dlang created dlang/dmd pull request #15984 "Fix issue 24316 - Allow CTFE access to immutable variable through poi…" fixing this issue:
- Fix issue 24316 - Allow CTFE access to immutable variable through pointer
https://github.com/dlang/dmd/pull/15984
Comment #2 by dlang-bot — 2024-01-02T22:09:08Z
dlang/dmd pull request #15984 "Fix issue 24316 - Allow CTFE access to immutable variable through poi…" was merged into master:
- 2d4845494058d4298cf1c73251111ff6558e85e4 by Tim Schendekehl:
Fix issue 24316 - Allow CTFE access to immutable variable through pointer
https://github.com/dlang/dmd/pull/15984