[Issue 19497] New: the program crash using dmd with -O, it works fine without optimizations.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 16 18:16:36 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19497

          Issue ID: 19497
           Summary: the program crash using dmd with -O, it works fine
                    without optimizations.
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: georges.toutoungis at gmail.com

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

--


More information about the Digitalmars-d-bugs mailing list