[gnu.gcc.bug] Bug passing large structures in gcc-1.32 on a Sun 3, SunOS 4.0

pphillip@CS.UBC.CA (Peter Phillips) (02/22/89)

The following program should produce the output:
0 1 2 3 4 5 6 7 8 9 a b c d e f
instead of
0 0 1 2 3 4 5 6 7 8 9 a b c d e

It was compile using gcc version 1.33 on a Sun 3/50 running SunOS 4.0
The configuration files were linked using config.gcc sun4-os4.

The structure is put onto the stack using bcopy and bcopy is passed
incorrect parameters.  I have included the assembler output from
gcc -v -g -S bug.c.

I hope you will be able to fix this.
Thank You,
Peter Phillips.

Script started on Tue Feb 21 12:17:22 1989
kootenay<1> cat bug.c
#define MAX 16

struct  foo {
        int e[MAX];
} bar;

main()
{
        int     i;

        for (i = 0; i < MAX; i++)
                bar.e[i] = i;
        dump(bar);
}

int dump(baz)
struct foo baz;
{
        int     i;

        for  (i = 0; i < MAX; i++)
                printf("%x ", baz.e[i]);

        printf("\n");
}
kootenay<2> gcc -g -o bug bug.c
kootenay<3> bug
0 0 1 2 3 4 5 6 7 8 9 a b c d e
kootenay<4> gcc -g -S bug.c
kootenay<5> cat bug.s
#NO_APP
gcc_compiled.:
        .stabs "bug.c",100,0,0,Ltext
Ltext:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.text
        .even
.globl _main
_main:
        .stabd 68,0,8
        link a6,#-4
LBB2:
        .stabd 68,0,11
        clrl a6@(-4)
L2:
        moveq #15,d1
        cmpl a6@(-4),d1
        jlt L3
        .stabd 68,0,12
        movel a6@(-4),d0
        asll #2,d0
        lea _bar,a0
        movel a6@(-4),a0@(d0:l)
        .stabd 68,0,11
L4:
        addql #1,a6@(-4)
        jra L2
L3:
        .stabd 68,0,13
        subw #64,sp
        movel sp,d0
        addql #4,d0
        pea 64:w
        movel d0,sp@-
        pea _bar
        jbsr _bcopy
        addw #12,sp
        jbsr _dump
LBE2:
        .stabd 68,0,14
L1:
        unlk a6
        rts
.stabs "foo:T16=s64e:17=ar1;0;15;1,0,512;;",128,0,0,0
.stabs "main:F1",36,0,0,_main
.stabs "i:1",128,0,0,-4
.stabn 192,0,0,LBB2
.stabn 224,0,0,LBE2
LC0:
        .ascii "%x \0"
LC1:
        .ascii "\12\0"
        .even
.globl _dump
_dump:
        .stabd 68,0,17
        link a6,#-4
LBB3:
        .stabd 68,0,21
        clrl a6@(-4)
L6:
        moveq #15,d1
        cmpl a6@(-4),d1
        jlt L7
        .stabd 68,0,22
        movel a6@(-4),d0
        movel a6@(8,d0:l:4),sp@-
        pea LC0
        jbsr _printf
        .stabd 68,0,21
        addqw #8,sp
L8:
        addql #1,a6@(-4)
        jra L6
L7:
        .stabd 68,0,24
        pea LC1
        jbsr _printf
LBE3:
        .stabd 68,0,25
L5:
        unlk a6
        rts
.stabs "dump:F1",36,0,0,_dump
.stabs "baz:p16",160,0,0,8
.stabs "i:1",128,0,0,-4
.stabn 192,0,0,LBB3
.stabn 224,0,0,LBE3
.stabs "bar:G16",32,0,0,0
.comm _bar,64
kootenay<6> exit
kootenay<7>
script done on Tue Feb 21 12:18:04 1989