This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/15387] New: Misscompilation in sibcall optimization


The following testcase aborts when compiled with -O2:

struct foo { int a, b, c; };

void
brother (int a, int b)
{
  if (a)
    abort ();
}


void
sister (struct foo f, int b)
{
  int *tmp = &f.b;

  brother (*tmp == b, b);
}

int
main (void)
{
  struct foo f;

  f.a = 7;
  f.b = 8;
  f.c = 9;
  sister (f, 1);
  exit (0);
}

The problem is that a sibcall is created for a call of brother, but the
arguments are rewritten in place.  Therefore first the place on the stack
where f.b is stored is rewritten by b, and then it is compared to b.

Probably caused by some interaction between the new way how the tail calls are
handled (information passed from tree level) and calls.c.

-- 
           Summary: Misscompilation in sibcall optimization
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rakdver at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,jh at suse dot cz
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]