This comes from the test suite, fail_compilation/fail135.d The code actually worked for a very long time (since around DMD1.000), but wasn't compiling because it had a missing import for printf. // segfault on 0.150 void fail135() { int i = 0; void fn() { asm { naked; lea EAX, i; mov [EAX], 42; ret; } } fn(); assert(i==42); } void main() { fail135(); }
I'm actually not sure if this should really work, or not. It may simply be code that was relying on undefined behaviour. Despite nominally being a "regression", it should be given low priority.
This is not caused by the compiler. The change seems to have been caused by a change in druntime between 2.052 and 2.053. This code didn't actually work before. If you change the assert to: assert(i==49); (which should fail), it doesn't fail! This code is actually clobbering the return address. The test case is bug 701, which hasn't been fixed. The bug is that this test case is in the test suite.
https://github.com/D-Programming-Language/dmd/commit/9224e1cae4b0d08898f4ee737c1ea510fc84fbdc