Created attachment 1452 [details] test case source code I get a segmentation fault with -O -release for the read of *src in the following partial function: --------8<-------- ubyte* src = …; uint c; final switch (pixelSize) { case 16: foreach (w; 0 .. count) { c = *src & 0b000_11111; c |= (*src++ & 0b111_00000) << (8-5); src++; c |= (*src & 0b0_00000_11) << (8+3); c |= (*src & 0b0_11111_00) << (16-2); src++; // *** problematic instruction (dst++).color = 0xFF000000 | (c << 3); } break; case 24: foreach (w; 0 .. count) { c = 0xFF000000 | *(src++) | (*(src++) << 8) | (*(src++) << 16); (dst++).color = c; } break; case 32: foreach (w; 0 .. count) { c = 0xFF000000 | *(src++) | (*(src++) << 8) | (*(src++) << 16); src++; (dst++).color = c; } break; } -------->8-------- If I change the location of the problematic instruction from: c |= (*src & 0b0_11111_00) << (16-2); src++; to: c |= (*src++ & 0b0_11111_00) << (16-2); I get no crash and the function completes. I was also able to fix it with a function call right before the snippet, so it is likely to be affected by CPU register allocation(?) When I created a test case and removed some files the crash with the -O -release switches disappeared but could be reproduced again with `dmd -O -release -inline main.d && ./main`. The test case requires the .tga file to work.
Created attachment 1453 [details] .tga for test case
Looks like this is fixed. Perhaps it's related to https://issues.dlang.org/show_bug.cgi?id=16225?
I reopened this issue, because I just downloaded the test case again and executed `dmd-2.073 -O -release -inline main.d && ./main`. It still crashes with following message: Parsing '640x480-16bit-RLE.tga' zsh: segmentation fault ./main
Compiling it for 64 bit Linux, the latest dmd, and with: dmd main dmd main -O dmd main -O -release -inline I get the following output each time: Parsing '640x480-16bit-RLE.tga' 640x480: 68175 No seg faults.