public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/2588: Bad alignment when passing structure by value to function
@ 2001-04-19 6:16 exco
0 siblings, 0 replies; only message in thread
From: exco @ 2001-04-19 6:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 2588
>Category: c
>Synopsis: Bad alignment when passing structure by value to function
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Apr 19 06:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Thierry EXCOFFIER
>Release: gcc version 2.95.3 20010315 (release)
>Organization:
>Environment:
IRIX b710sibn 6.5 01101246 IP32
>Description:
For some structure size, when the structure is
passed by value to a function, its content is incorrect.
>How-To-Repeat:
/* The problem always appear when size D+F > 16 and F odd */
#define D 14
#define F 3
typedef struct
{
int a[D] ;
} DoubleAlignment ;
typedef struct
{
int a[F] ;
} FloatAlignment ;
void display(FloatAlignment x, DoubleAlignment y)
{
int i ;
for(i=0;i<F;i++)
if ( x.a[i] != 100+i )
printf("ERROR : x.a[%d] = %d != %d\n", i, x.a[i], 100+i) ;
for(i=0;i<D;i++)
if ( y.a[i] != 200+i )
printf("ERROR : y.a[%d] = %d != %d\n", i, y.a[i], 200+i) ;
}
int main()
{
FloatAlignment x ;
DoubleAlignment y ;
int i ;
printf("D=%d F=%d\n", D, F) ;
for(i=0;i<F;i++)
x.a[i] = 100+i ;
for(i=0;i<D;i++)
y.a[i] = 200+i ;
display(x, y) ;
return(0) ;
}
>Fix:
Use -O3 option when compiling.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-04-19 6:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-19 6:16 c/2588: Bad alignment when passing structure by value to function exco
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).