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
Comment #1 by ag0aep6g — 2018-12-21T12:28:05Z
Comment #2 by github-bugzilla — 2019-01-02T05:50:59Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/2ede66c6a9c49f9100501833d7d3e359b05ff336 fix issue 19497 - the program crash using dmd with -O, it works fine without optimizations. https://github.com/dlang/dmd/commit/973c00096e28d0b93834310f6e7ad9e118274004 Merge pull request #9113 from aG0aep6G/19497 fix issue 19497 - the program crash using dmd with -O, it works fine …