https://issues.dlang.org/show_bug.cgi?id=23342
Issue ID: 23342
Summary: ImportC: Array compound literals use the GC
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
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.
--