c/2520: IA64 parameter passing wrong for some structures

mark.dewing@intel.com mark.dewing@intel.com
Mon Apr 9 13:26:00 GMT 2001


>Number:         2520
>Category:       c
>Synopsis:       IA64 parameter passing wrong for some structures
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 09 13:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Mark Dewing
>Release:        gcc version 3.0 20010402
>Organization:
>Environment:
IA64 Linux 2.4.0test10-001115-58smp
>Description:
For structures larger than 16 bytes, and when several
of them are passed by value, the ones on the end of the
parameter list get passed incorrectly.
>How-To-Repeat:

struct my_struct {
  long m1;
  long m2;
  long m3;
  long m4;
};
//__attribute((aligned(16)));
// using this alignment make it work


void level1( int *this,
             struct my_struct s1,
             struct my_struct s2,
             struct my_struct s3,
             struct my_struct s4,
             int x
            )   {

   printf("s1 %#lx\n",s1.m1);
   printf("s2 %#lx\n",s2.m1);
   printf("s3 %#lx\n",s3.m1);
   printf("s4 %#lx\n",s4.m1);
   printf("x %#lx\n",x);
}

main(){
   int* this;
   int a=1,b=2,c=3,d=4,x=5;
   struct my_struct s1,s2,s3,s4;

   s1.m1 = a;
   s2.m1 = b;
   s3.m1 = c;
   s4.m1 = d;

   printf("sizeof struct %d\n",sizeof(struct my_struct));
// only  a problem if size of struct > 16
   printf("s1 %#lx\n",s1.m1);
   printf("s2 %#lx\n",s2.m1);
   printf("s3 %#lx\n",s3.m1);
   printf("s4 %#lx\n",s4.m1);
   printf("x = %#lx\n",x);
   printf("\n");
   level1(this,s1,s2,s3,s4,x);

}
/* sample output 
sizeof struct 32
s1 0x1
s2 0x2
s3 0x3
s4 0x4
x = 0x5

s1 0x1
s2 0x2
s3 0
s4 0
x 0
*/

>Fix:
A workaround is possible by adding an attribute to
make the structure 16 byte aligned.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list