www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23342] New: ImportC: Array compound literals use the GC


          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: nobody puremagic.com
          Reporter: dave287091 gmail.com 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. --
Sep 17 2022