Bug 23342 – ImportC: Array compound literals use the GC
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-09-18T04:11:25Z
Last change time
2022-10-10T12:57:32Z
Keywords
ImportC
Assigned to
No Owner
Creator
dave287091
Comments
Comment #0 by dave287091 — 2022-09-18T04:11:25Z
6.5.2.4.5 states:
> The value of the compound literal is that of an unnamed object initialized by the initializer list. If the compound literal occurs outside the body of a function, the object has static storage duration; otherwise, it has automatic storage duration associated with the enclosing block.
ImportC apparently creates them with the GC, as evidenced with the following C program:
// arr.c
int main(){
int* p = (int[]){3}; // Error: expression `[3]` uses the GC and cannot be used with switch `-betterC`
return 0;
}
Compiling it with -betterC reveals the problem.
Comment #1 by razvan.nitu1305 — 2022-10-10T05:22:43Z