This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11268] New: corrupted arg values/addresses when passed to a function
- From: "umuta at us dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2003 17:35:55 -0000
- Subject: [Bug c/11268] New: corrupted arg values/addresses when passed to a function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11268
Summary: corrupted arg values/addresses when passed to a function
Product: gcc
Version: 2.96 (redhat)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: umuta@us.ibm.com
CC: gcc-bugs@gcc.gnu.org
%gcc -v
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)
consider the below c code:
a.c:
#include <stdio.h>
typedef struct problem
{
unsigned int data[2];
short sign;
} problem_t;
static int func1(int i1, int i2, int i3,
int i4, int i5, int i6, int i7,
problem_t p1, problem_t p2, problem_t p3,
problem_t p4, problem_t *p5);
main()
{
problem_t p1,p2,p3,p4,p5;
problem_t tmp;
int rc;
tmp.data[0]=0;
tmp.data[1]=0;
tmp.sign=1;
p1 = p2 = tmp;
tmp.data[0]=1;
tmp.data[1]=0;
tmp.sign=-1;
p3 = tmp;
tmp.data[0]=0;
tmp.data[1]=0;
tmp.sign=0;
p4 = tmp;
printf("Values Before Calling func1()\n");
printf("i1 = %d\n",1);
printf("i2 = %d\n",2);
printf("i3 = %d\n",3);
printf("i4 = %d\n",4);
printf("i5 = %d\n",5);
printf("i6 = %d\n",6);
printf("i7 = %d\n",7);
printf("p1= {data = {%d , %d}, sign = %d}\n",p1.data[0],p1.data[1],p1.sign);
printf("p2= {data = {%d , %d}, sign = %d}\n",p2.data[0],p2.data[1],p2.sign);
printf("p3= {data = {%d , %d}, sign = %d}\n",p3.data[0],p3.data[1],p3.sign);
printf("p4= {data = {%d , %d}, sign = %d}\n",p4.data[0],p4.data[1],p4.sign);
printf("p5= %p\n",&p5);
printf("\n");
rc = func1(1,2,3,4,5,6,7,p1, p2, p3, p4, &p5);
}
static int
func1(
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7,
problem_t p1,
problem_t p2,
problem_t p3,
problem_t p4,
problem_t *p5)
{
printf("Values Inside func1()\n");
printf("i1 = %d\n",i1);
printf("i2 = %d\n",i2);
printf("i3 = %d\n",i3);
printf("i4 = %d\n",i4);
printf("i5 = %d\n",i5);
printf("i6 = %d\n",i6);
printf("i7 = %d\n",i7);
printf("p1= {data = {%d , %d}, sign = %d}\n",p1.data[0],p1.data[1],p1.sign);
printf("p2= {data = {%d , %d}, sign = %d}\n",p2.data[0],p2.data[1],p2.sign);
printf("p3= {data = {%d , %d}, sign = %d}\n",p3.data[0],p3.data[1],p3.sign);
printf("p4= {data = {%d , %d}, sign = %d}\n",p4.data[0],p4.data[1],p4.sign);
printf("p5= %p\n",p5);
return 0;
}
%gcc -o a a.c
%a
Values Before Calling func1()
i1 = 1
i2 = 2
i3 = 3
i4 = 4
i5 = 5
i6 = 6
i7 = 7
p1= {data = {0 , 0}, sign = 1}
p2= {data = {0 , 0}, sign = 1}
p3= {data = {1 , 0}, sign = -1}
p4= {data = {0 , 0}, sign = 0}
p5= 0x60000fffffffb800
Values Inside func1()
i1 = 1
i2 = 2
i3 = 3
i4 = 4
i5 = 5
i6 = 6
i7 = 7
p1= {data = {0 , 0}, sign = 1}
p2= {data = {0 , 0}, sign = 0}
p3= {data = {1 , 0}, sign = 1}
p4= {data = {65535 , 0}, sign = 0}
p5= (nil)