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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 26 14:53:08 UTC 2017


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

FeepingCreature <default_357-line at yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line at yahoo.de

--- Comment #1 from FeepingCreature <default_357-line at yahoo.de> ---
Simplified a bit:

struct Array
{
    long length, ptr;
}

struct Struct
{
    bool b = true;
}

void fun1(int) { }

void fun2(Array arr, int, int)
{
    assert(!arr.length);
}

void fn(Struct* str)
{
    Array arr;
    if (!str) return;
    if (str)
    {
        fun1(str.b);
    }
    if (str.b)
    {
        fun2(arr, str.b, 0);
    }
}

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

--


More information about the Digitalmars-d-bugs mailing list