[Issue 22154] New: Pure functions should be able to use only the address of a global

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 28 15:50:19 UTC 2021


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

          Issue ID: 22154
           Summary: Pure functions should be able to use only the address
                    of a global
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrei at erdani.com

Consider:

__gshared int a;

pure int fun(int* x) {
    if (x == &a) return 1;
    return 42;
}

This does not compile. However, it does not depend on global modifiable state
because the address of a global is a runtime invariant.

--


More information about the Digitalmars-d-bugs mailing list