This program is tweaked to cause a crash when building for Win32:
import std.array;
void main()
{
auto arr = appender!string();
asm { mov EBX,-1; }
arr.put("1");
}
>dmd -inline -O -g test.d
>test
object.Error: Integer Divide by Zero
----------------
0x004222B6 in _ULDIV
0x00404D2A in stdarrayAppender at m:\s\d\rainers\phobos\std\array.d(2453)
0x004234C0 in memset
0x0040F76E in _d_newitemT
0x00405AC0 in stdarrayAppender at m:\s\d\rainers\phobos\std\array.d(2339)
0x0040E5F8 in rtdmain2_d_run_mainrunAll__lambda1
0x0040E5CB in rtdmain2_d_run_mainrunAll
0x0040E4E1 in _d_run_main
0x0040CD90 in main at M:\s\d\rainers\bugs\rs165\test.d(3)
0x75EC850D in BaseThreadInitThunk
0x77DDBF39 in RtlInitializeExceptionChain
0x77DDBF0C in RtlInitializeExceptionChain
This is caused by the bsr intrinsic having undefined behaviour for 0 (i.e. the previous value of the destination register is preserved).
(In reply to comment #0)
> This program is tweaked to cause a crash when building for Win32:
>
> import std.array;
>
> void main()
> {
> auto arr = appender!string();
> asm { mov EBX,-1; }
> arr.put("1");
> }
>
> >dmd -inline -O -g test.d
> >test
> object.Error: Integer Divide by Zero
Out of curiosity, did you "encounter" this bug out in the wild, and reduce it to this, or did you see it in the code, and write this specifically?
Comment #4 by r.sagitario — 2013-11-17T09:28:34Z
(In reply to comment #3)
> Out of curiosity, did you "encounter" this bug out in the wild, and reduce it
> to this, or did you see it in the code, and write this specifically?
It caused initialization of Visual D to crash, but only the optimized release build.
I checked the commit history, and it seemed that the change was introduced after 2.064 was built.