[Issue 22592] New: importC: Segmentation fault indexing global array at run-time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 12 21:06:09 UTC 2021


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

          Issue ID: 22592
           Summary: importC: Segmentation fault indexing global array at
                    run-time
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

Compile with -betterC and run the resultant executable.
---
/* Comment out the next line to make the segfault go away.  */
int testfn (void);

typedef struct config_s {
   short field;
} config;

static const config table[10] = {
    {0}, {4}, {5}, {6}, {4}, {16}, {16}, {32}, {128}, {258}
};

int testfn ()
{
    return table[6].field;
}

int main()
{
    testfn();
}
---

--


More information about the Digitalmars-d-bugs mailing list