www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12503] New: Bad optimization with scope(success) and return statement

https://d.puremagic.com/issues/show_bug.cgi?id=12503

           Summary: Bad optimization with scope(success) and return
                    statement
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice, wrong-code
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow gmail.com> 2014-04-01
20:28:04 EEST ---
//////////// test.d ///////////
void check(string a, string b)
{
    assert(a != b);
}

void fun(string a)
{
    auto b = a;
    scope(success) check(a, b);
    a = null;
    return;
}

void main()
{
    fun("foo");
}
///////////////////////////////

When compiled with -O, the assert fails. (a still has the same value as b).

When compiled with -m64, the compiler ICEs:
Internal error: ..\ztc\cgobj.c 1479

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 01 2014