[Issue 24316] New: Allow CTFE access to immutable variable through pointer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 2 18:10:29 UTC 2024


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

          Issue ID: 24316
           Summary: Allow CTFE access to immutable variable through
                    pointer
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: tim.dlang at t-online.de

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

--


More information about the Digitalmars-d-bugs mailing list