target/6265: arm-elf toolchain wrong reference to varibles or stack address when using -O2 option
davidwu@arcturusnetworks.com
davidwu@arcturusnetworks.com
Thu Apr 11 14:00:00 GMT 2002
>Number: 6265
>Category: target
>Synopsis: arm-elf toolchain wrong reference to varibles or stack address when using -O2 option
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 11 13:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: davidwu@arcturusnetworks.com
>Release: gcc 2.95.3/ gcc 3.1
>Organization:
>Environment:
Linux version 2.4.4-4GB (gcc version 2.95.3 20010315 (SuSE)) #1 Sat Jun 23 05:26:59 GMT 2001
>Description:
the following codes(file1) compile and execute correctly without using -O2
option. But when using -O2 option, the struct P3 is wrong(gcc 2.95) or
Struct P2(gcc 3.1) is wrong.
when using one "printf"( or just unuse bar()),it will be correct.
//======================
typedef struct {
long int p_x, p_y;
} Point;
void
bar ()
{
}
void
f (p0, p1, p2, p3, p4, p5)
Point p0, p1, p2, p3, p4, p5;
{
printf("p0x=%d\n",p0.p_x);
printf("p0y=%d\n",p0.p_y);
printf("%d\n",p1.p_x);
printf("%d\n",p1.p_y);
printf("%d\n",p2.p_x);
printf("%d\n",p2.p_y);
printf("%d\n",p1.p_x);
printf("%d\n",p1.p_y);
printf("%d\n",p2.p_x);
printf("%d\n",p2.p_y);
printf("%d\n",p3.p_x);
printf("%d\n",p3.p_y);
printf("%d\n",p4.p_x);
printf("%d\n",p4.p_y);
printf("%d\n",p5.p_x);
printf("%d\n",p5.p_y);
}
void
foo ()
{
Point p0, p1, p2, p3, p4, p5;
bar();
p0.p_x = 0;
//printf("%d\n",p0.p_x);
p0.p_y = 1;
p1.p_x = -1;
p1.p_y = 0;
p2.p_x = 1;
p2.p_y = -1;
p3.p_x = -1;
p3.p_y = 1;
p4.p_x = 0;
p4.p_y = -1;
p5.p_x = 1;
p5.p_y = 0;
f(p0,p1,p2,p3,p4,p5);
}
int
main()
{
foo ();
exit(0);
}
//========= end =======
>How-To-Repeat:
configure arm-elf cross gcc with simulator(gdb has a simulator)
compile above file with -O2 and execute.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list