[Issue 5790] New: "Error: variable result used before set" when -release -inline -O

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 28 05:57:40 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5790

           Summary: "Error: variable result used before set" when -release
                    -inline -O
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jordi at rovira.cat


--- Comment #0 from Jordi Rovira i Bonet <jordi at rovira.cat> 2011-03-28 05:54:10 PDT ---
When compiling the following code with 

dmd -c -release -inline -O resource.d

I get the message "Error: variable result used before set" without any line
information, and compilation fails.

This happens only with the flags above. Removing any of them, or compiling in
debug results in good output. I have verified that this error happens both in
linux and windows, with dmd 2.052 and since many versions ago. 

<Speculation>
Even GDC crashes compiling this code in release, which makes me think it is in
the front end.

<Data>
I have removed everything i could, and now the code doesn't make much sense,
but the file resource.d is:

module     bug;

import     std.c.string;

class InputStream
{
public:

    InputStream opShr(T)( out T result )
    {
        memcpy( &result, &m_data[m_pos], T.sizeof );
        m_pos += T.sizeof;

        return this;
    } 

    int m_pos;
    const ubyte[] m_data;
}

struct GUID
{
    uint m_values[4];
};

struct Header
{
    int ver;
    int siz;
    GUID id;
}

void LoadResourceLegacyHeader( InputStream f, out Header header )
{
    f >> header.id;
}

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


More information about the Digitalmars-d-bugs mailing list