www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23053] New: importC: can't take address of some

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

          Issue ID: 23053
           Summary: importC: can't take address of some compound-literals
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

void fn()
{ 
        int *a = &(int[1]){0};
        int *b = &(int){0};
}

test.c(3): Error: `[0]` is not an lvalue and cannot be modified
test.c(4): Error: cannot modify constant `0`

array one works if & is removed

int one should be the same as taking the address of a local variable typed
"int"

--
Apr 24 2022