Hello, All !

I found a significant BUG when using struct assignment.

Here is the sample:

struct x{
int a,b,c,d;
};

struct x *v[2];

void swap(void)
{
struct x tmp;
 tmp=*v[0];
 *v[0]=*v[1];
 *v[1]=tmp;
}

And here is GCC's listing (with -O option):

/***********************
 * Function `swap' 
 ***********************/
swap:
/* prologue: frame size = 8 */
.L__FrameSize_swap=0x8
.L__FrameOffset_swap=0x8
 sub #8, r1 ; 8, fpn 0
/* prologue end (size=1) */
 mov &v, r15 
 mov @r15+, @r1
 mov @r15+, 2(r1)
 mov @r15+, 4(r1)
 mov @r15+, 6(r1)
 mov &v+2, r14 
 mov @r14+, 0(r15)
 mov @r14+, 2(r15)
 mov @r14+, 4(r15)
 mov @r14+, 6(r15)
 mov &v+2, r15 
 mov @r1+, 0(r15)       ;We should not change the stack pointer here !
 mov @r1+, 2(r15)
 mov @r1+, 4(r15)
 mov @r1+, 6(r15)
/* epilogue: frame size=8 */
 add #8, r1                    ;After this command the stack pointer points to 
the illegal location !
 ret
/* epilogue end (size=2) */
/* function swap size 33 (30) */


I use win32 version (from 10.12.2002).
Thanks, Oleg.

Reply via email to