c/10142: gcc -m64 produces wrong code when passing struct as parameter
p.van-hoof@qub.ac.uk
p.van-hoof@qub.ac.uk
Wed Mar 19 01:11:00 GMT 2003
>Number: 10142
>Category: c
>Synopsis: gcc -m64 produces wrong code when passing struct as parameter
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Tue Mar 18 23:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Peter van Hoof
>Release: 3.2.2
>Organization:
Queen's University of Belfast
>Environment:
System: SunOS scooby 5.9 Generic_112233-04 sun4u sparc SUNW,Sun-Blade-100
Architecture: sun4
host: sparc-sun-solaris2.9
build: sparc-sun-solaris2.9
target: sparc-sun-solaris2.9
configured with: /opt/temp/gcc-3.2.2/configure --prefix=/opt/local --enable-threads
>Description:
In the program below, a struct is passed as a parameter to a routine.
This is clearly done incorrectly, as demonstrated by the print statements.
This bug is triggered by the -m64 flag on the command line, even in
non-optimized mode.
This bug is present in gcc 3.2.2, as well as 3.3 and 3.4.
>How-To-Repeat:
scooby> gcc h.c
scooby> a.out
1.20e+00 25
1.20e+00 25
scooby> gcc -m64 h.c
scooby> a.out
1.20e+00 25
1.20e+00 -2147488472
scooby> cat h.c
typedef struct {
double m;
long x;
} mx;
void b(int i1,int i2,int i3,int i4,int i5,int i6,mx m)
{
printf("%.2e %ld\n",m.m,m.x);
}
int main() {
mx z={1.2, 25};
printf( "%.2e %ld\n", z.m, z.x );
b(1,2,3,4,5,6,z);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list