[Issue 22513] New: ImportC: address of member of struct can’t be taken at compile time.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 14 22:43:08 UTC 2021


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

          Issue ID: 22513
           Summary: ImportC: address of member of struct can’t be taken at
                    compile time.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dave287091 at gmail.com

The following valid C code fails to compile:

// staticvar.c
int x = 0; 
int* y = &x; // ok

struct Foo {
    int x;
};

struct Foo f = {3};
int* z = &f.x; // error

The message is:

staticvar.c(10): Error: static variable `f` cannot be read at compile time

--


More information about the Digitalmars-d-bugs mailing list