Bug 19497 – the program crash using dmd with -O, it works fine without optimizations.
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-12-16T18:16:36Z
Last change time
2019-01-02T05:51:02Z
Keywords
wrong-code
Assigned to
No Owner
Creator
George Toutoungis
Comments
Comment #0 by georges.toutoungis — 2018-12-16T18:16:36Z
module t;
import std.stdio;
void main()
{
ubyte[1024] data;
ushort* ushortPtr = cast(ushort*) data.ptr;
*ushortPtr++ = 0xfe00;
writefln("ushortPtr(%s)", ushortPtr);
std.stdio.stdout.flush;
}
this little program crash with: dmd -O t.d
it works fine without the -O switch.
-------------------------------------------------------
module t;
import std.stdio;
void main()
{
ubyte[1024] data;
ushort* ushortPtr = cast(ushort*) data.ptr;
*ushortPtr = 0xfe00;
ushortPtr++;
writefln("ushortPtr(%s)", ushortPtr);
std.stdio.stdout.flush;
}
this little modification, solve the problem.
no problem with ldc2.
the test done on MacOS, dmd v2.083.1
Thanks,
Georges Toutoungis