Consider the following code: void main() { shared int[int] ints = [6: 8]; auto bla = (6 in ints); } The following console output is returned when running this code in release mode: $ dub run --build=release Performing "release" build using dmd for x86. assocbug ~master: building configuration "application"... Linking... Running .\assocbug.exe object.Error@(0): Access Violation ---------------- 0x0040249A 0x004023B3 0x004022B4 0x004020A8 0x76C962C4 in BaseThreadInitThunk 0x77520FD9 in RtlSubscribeWnfStateChangeNotification 0x77520FA4 in RtlSubscribeWnfStateChangeNotification Program exited with code 1 This seems to only happen in release builds and not debug builds. Furthermore as far I could test, it seems to only happen on Windows. Details: DMD32 D Compiler v2.072.2 Windows 10 x86_64 DUB version 1.1.2
I was able to replicate this bug on Arch Linux (64bit), dmd v2.073.0. I get a segfault whenever I run this code: void main() { shared int[int] ints = [6: 8]; auto bla = (6 in ints); } However, when I compile and run it with ldc 1:1.0.0-1 I get 0 segfaults and it runs correctly. When I separated the declaration and the assignment like below it worked in both compilers. void main() { shared int[int] ints; ints[6] = 8; auto bla = (6 in ints); }
In DMD 2.075.0 (DMD32 D Compiler v2.075.0) this issue also seems to happen in debug mode, with the following stack trace: object.Error@(0): Access Violation ---------------- 0x004028CA in _d_assocarrayliteralTX 0x0040257F in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv 0x00402543 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() 0x00402444 in _d_run_main 0x0040222C in main at D:\Temp\assocbug\source\app.d(7) 0x0041F131 in mainCRTStartup 0x76208744 in BaseThreadInitThunk 0x7755582D in RtlGetAppContainerNamedObjectPath 0x775557FD in RtlGetAppContainerNamedObjectPath Program exited with code 1 Using the code from the original post
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17341 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB