Article View: gnu.gcc.bug
Article #1079struct returns in 2.2.2 + cc under SunOS 8-(
From: Derek Jones
Date: Mon, 07 Sep 1992 13:43
Date: Mon, 07 Sep 1992 13:43
90 lines
2319 bytes
2319 bytes
Problems with struct returns from cc compiled code and gcc compiled
code under SunOS.
Header file:
/* smc_struct.h */
#include <stdio.h>
typedef struct
{
int a;
double b;
} smc_struct;
Code to be compiled with cc on a sun....
/* smc_cc.c */
#include "smc_struct.h"
smc_struct func(smc1)
smc_struct smc1;
{
smc_struct smc2;
smc2.a = 35; smc2.b = 39.425;
printf("smc1.a = %d, smc1.b= %lf\n", smc1.a, smc1.b);
printf("smc2.a = %d, smc2.b= %lf\n", smc2.a, smc2.b);
return smc2;
}
Now, code to be compiled with gcc on a sun....
/* smc_gcc.c */
#include "smc_struct.h"
extern smc_struct func(smc_struct);
int main(void)
{
smc_struct smc_main;
smc_main.a = 11; smc_main.b = 88.793;
smc_main = func(smc_main);
printf("smc_main.a = %d, smc_main.b= %lf\n",
smc_main.a, smc_main.b);
return 0;
}
The gcc command line was tried with and without the -fpcc-struct-return
flag viz:
cc -c -g smc_cc.c
gcc -c -g -fpcc-struct-return smc_gcc.c
gcc -g -fpcc-struct-return -o smc_test smc_cc.o smc_gcc.o
****BUT*** running the program gives:
smc1.a = 11, smc1.b= 88.793000
smc2.a = 35, smc2.b= 39.425000
%1 29303 Illegal instruction - core dumped smc_test
It seemed as though this was fixed in 2.2.1 (unless I missed it), but
is now broken again. Any ideas?
Running 2.2.2 on Sunos 4.1.1 / 4.1.2 on sparc.
(Please reply to derek@aivru.sheffield.ac.uk in preference to the return address
of this message as I don't pick up this mail too frequently, and I don't
read this news group regularly),
Many Thanks
Derek Jones
--
Derek Jones, System Manager, AI Vision Research Unit, University of Sheffield ,
Sheffield, S10 2TN, UK Tel:(+44) (0)742 768555 X 6551 Fax:(+44) (0)742 766515
email: derek@aivru.sheffield.ac.uk derek@ibmpcug.co.uk
Compu$: 70374,1355
Technical Details
Message-ID:
<Bu7nH2.qH@ibmpcug.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!ibmpcug.co.uk!derekShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!ibmpcug.co.uk!derek From: derek@ibmpcug.co.uk (Derek Jones) Subject: struct returns in 2.2.2 + cc under SunOS 8-( Message-ID: <Bu7nH2.qH@ibmpcug.co.uk> Sender: gnulists@ai.mit.edu Organization: The IBM PC User Group, UK. Distribution: gnu Date: Mon, 7 Sep 1992 13:43:49 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 91