[Bug optimization/11269] New: [tree-ssa] wrong-code

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jun 20 18:35:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11269

           Summary: [tree-ssa] wrong-code
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P1
         Component: optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: reichelt@gcc.gnu.org
                CC: dnovillo@gcc.gnu.org,gcc-bugs@gcc.gnu.org
  GCC host triplet: i686-pc-linux-gnu

The following code snippet (inspired by PR6189) should return "1",
but does not, if optimization on the tree-ssa-branch is turned on.

---------------------------------------------------------------
struct A
{
    int  x[2];
    int& GetFirst() { return x[0]; }
};


A foo ()
{
    A a;
    a.GetFirst()=1;
    return a;
}


int main()
{
    A b=foo();
    return b.GetFirst();
}
---------------------------------------------------------------

Without optimization I get the return value "1", with "-O" or "-O2"
I get "192" and with "-O3" I get "0".

This is a regression w.r.t. mainline.



More information about the Gcc-bugs mailing list