[Issue 23024] New: Large static array causes access violation on Windows with DMD

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 17 02:28:23 UTC 2022


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

          Issue ID: 23024
           Summary: Large static array causes access violation on Windows
                    with DMD
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andy.pj.hanson at gmail.com

This program breaks on Windows when compiled with DMD:

```
import core.stdc.stdio : printf;

static ulong[0x100000] data;

extern(C) void main() {
        foreach (immutable size_t i; 0 .. data.length) {
                printf("Write to data[%llu]\n", i);
                data[i] = 42;
        }
        printf("Success\n");
}
```

The issue is an access violation. 
`dmd -m64 a.d && .\a.exe` fails before writing data[1007].
`dmd -m64 -g a.d && .\a.exe` fails before writing data[6].

(Removing the -m64 doesn't help. The difference with `-g` may be related to
https://issues.dlang.org/show_bug.cgi?id=21763 .)

`ldc2 a.d && .\a.exe` succeeds. And both dmd and ldc2 work on Linux.

I'm testing this on a VMWare virtual machine in case that matters.

Tested with dmd `v2.099.1-dirty`.

--


More information about the Digitalmars-d-bugs mailing list