This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/29683] New: Arg split between stack/regs can cause stack corruption
- From: "jconner at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Nov 2006 19:03:45 -0000
- Subject: [Bug middle-end/29683] New: Arg split between stack/regs can cause stack corruption
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
On targets which allow a function argument to be split between registers and
the stack, values can be corrupted by later function calls.
Specifically - this code:
~~~~~~~~~~
/* { dg-do run } */
/* { dg-options "-Os -fno-inline-functions" } */
void abort (void);
typedef struct {
int x[7];
} agg7;
typedef struct {
int mbr1;
int mbr2;
} agg2;
int expected = 31415;
agg7 filler;
int GetConst (agg7 filler, agg2 split)
{
return expected;
}
void VerifyValues (agg7 filler, int last_reg, int first_stack, int
second_stack)
{
if (first_stack != 123 || second_stack != expected)
abort ();
}
void RunTest (agg2 a)
{
int result;
result = GetConst (filler, a);
VerifyValues (filler, 0, a.mbr1, result);
}
int main(void)
{
agg2 result = {123, 456};
RunTest (result);
return 0;
}
~~~~~~~~~~
compiled with "gcc -O1" incorrectly aborts.
--
Summary: Arg split between stack/regs can cause stack corruption
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jconner at apple dot com
GCC host triplet: powerpc-apple-darwin8
GCC target triplet: powerpc-apple-darwin8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29683