[Issue 17940] New: bool function parameters loaded from struct sometimes miscompiled with -O

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 26 14:31:36 UTC 2017


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

          Issue ID: 17940
           Summary: bool function parameters loaded from struct sometimes
                    miscompiled with -O
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: belka at caraus.de

Code (test.d):

struct Array
{
    long length, ptr;
}

struct Struct
{
    bool b1 = true, b2;
}

void fun(Array arr, int, int)
{
    if (arr.length != 0) asm { int 3; }
}

void fn(Struct* str)
{
    Array arr;
    if (!str) return;
    if (str.b1)
    {
        fun(arr, str.b2, 0);
    }
    if (str.b1)
    {
        fun(arr, str.b1, 0);
    }
}

void main()
{
    Struct s;
    fn(&s);
}

Then:

dmd -O test.d  && ./test

causes "Trace/breakpoint trap"

--


More information about the Digitalmars-d-bugs mailing list