Bug 23053 – importC: can't take address of some compound-literals

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-24T22:58:28Z
Last change time
2024-12-13T19:22:25Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
duser
Moved to GitHub: dmd#20092 →

Comments

Comment #0 by duser — 2022-04-24T22:58:28Z
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"
Comment #1 by bugzilla — 2022-09-23T08:48:51Z
clang gives a warning: test.c:4:7: warning: incompatible pointer types initializing 'int *' with an expression of type 'int (*)[1]' [-Wincompatible-pointer-types] int *a = &(int[1]){0};
Comment #2 by bugzilla — 2023-04-09T06:01:04Z
The first line compiles successfully now. The second one does not.
Comment #3 by robert.schadek — 2024-12-13T19:22:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20092 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB