www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIyNTEzXSBOZXc6IEltcG9ydEM6IGFkZHJlc3Mgb2Yg?=

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 puremagic.com
          Reporter: dave287091 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

--
Nov 14 2021