Article View: gnu.gcc.bug
Article #1129suncc vs gcc align
From: John Lewis
Date: Sat, 12 Sep 1992 03:40
Date: Sat, 12 Sep 1992 03:40
41 lines
1735 bytes
1735 bytes
Hi,
In recompiling a file under gcc 2.2.2 (on sparc2), it seems like gcc
is handling double alignment in a structure differently
than previous versions.
The file needs to be linked with some files compiled with the
normal sun cc; thus I specified -fpcc-struct-return, which did not help.
The following self-contained program illustrates the problem.
The program runs using the sun cc compilation line but fails with a
buss error when run with either of the gcc lines.
================
/*% cc % -o junk %* OK
*% gcc % -o junk %* BUS ERROR
*% gcc -fpcc-struct-return % -o junk %* BUS ERROR
*/
#include <stdio.h>
#include <stdlib.h>
struct S_Flonum { /* structure containing double */
int tag;
double val;
};
typedef unsigned Object;
#define FLONUM(x) ((struct S_Flonum *)(x))
main() {
char *p;
Object num;
unsigned long a;
p = malloc(sizeof(struct S_Flonum) + 100); /* result is 8-aligned */
p += 4; /* make it aligned on 4*/
num = (int)p;
FLONUM(num)->val = 3.1415927; /* BUSS ERROR here if 4-aligned */
a = (unsigned long)&(FLONUM(num)->val);
printf("val @ %d, 4=%d,8=%d\n",a,4*(a/4),8*(a/8)); fflush(stdout);
printf("val=%f\n",FLONUM(num)->val);
}
Technical Details
Message-ID:
<1992Sep12.034001.4232@research.nj.nec.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!nj.nec.com!zillaShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!nj.nec.com!zilla From: zilla@nj.nec.com (John Lewis) Subject: suncc vs gcc align Message-ID: <1992Sep12.034001.4232@research.nj.nec.com> Sender: gnulists@ai.mit.edu Organization: C&C Research Labs, NEC USA, Princeton, N.J. Distribution: gnu Date: Sat, 12 Sep 1992 03:40:01 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 42