This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Pass direct unsigned long long values to a function problems


Hi,

so I am confronted to a problem with GCC 2.95.2. The problem occured on
x86 and PPC platforms (I suppose that it's can be reproduced on other 32
bits architectures).
You can find below a source which can reproduces the error, and the best
thing is to let GCC stop to the .S generation and see the assembly file
content.

The commands lines used are : gcc -S toto.c  , gcc -S
-fomit-frame-pointer -O2 toto.c

Is someone tell me if it's really a bug, and if there's a work around.

Regards,
Emmanuel Poitier

-------------------------------- toto.c --------------------------------

void func1(void* mem, void* mem1, unsigned long long i) {
    unsigned long long j = 0;
    for( ; j<i ; j++) ((char*)mem)[j] = ((char*)mem1)[j];
}

void func2(unsigned long long i,void* mem, void* mem1) {
    unsigned long long j = 0;
    for( ; j<i ; j++) ((char*)mem)[j] = ((char*)mem1)[j];
}

int main() {
    void *mem, *mem1;

    func1(mem, mem1, sizeof(unsigned long)*1073741824);
    func1(mem, mem1, sizeof(unsigned long)*0x40000000);

    func2(sizeof(unsigned long)*1073741824, mem, mem1);
    func2(sizeof(unsigned long)*0x40000000, mem, mem1);
}
---------------------------------------------------------------------

--------------------------------- toto.s -------------------------------

 .file "toto.c"
 .version "01.01"
gcc2_compiled.:
.text
 .align 16
.globl func1
 .type  func1,@function
func1:
 pushl %ebp
 movl %esp,%ebp
 subl $24,%esp
 movl $0,-8(%ebp)
 movl $0,-4(%ebp)
 .p2align 4,,7
.L3:
 movl 20(%ebp),%eax
 cmpl -4(%ebp),%eax
 ja .L6
 movl 20(%ebp),%eax
 cmpl -4(%ebp),%eax
 jne .L7
 movl 16(%ebp),%eax
 cmpl -8(%ebp),%eax
 ja .L6
 movl 16(%ebp),%eax
 cmpl -8(%ebp),%eax
 jne .L7
 jmp .L7
 .p2align 4,,7
.L7:
 jmp .L4
 .p2align 4,,7
.L6:
 movl 8(%ebp),%eax
 movl -8(%ebp),%edx
 addl %edx,%eax
 movl 12(%ebp),%edx
 movl -8(%ebp),%ecx
 addl %ecx,%edx
 movb (%edx),%cl
 movb %cl,(%eax)
.L5:
 addl $1,-8(%ebp)
 adcl $0,-4(%ebp)
 jmp .L3
 .p2align 4,,7
.L4:
.L2:
 movl %ebp,%esp
 popl %ebp
 ret
.Lfe1:
 .size  func1,.Lfe1-func1
 .align 16
.globl func2
 .type  func2,@function
func2:
 pushl %ebp
 movl %esp,%ebp
 subl $24,%esp
 movl $0,-8(%ebp)
 movl $0,-4(%ebp)
 .p2align 4,,7
.L9:
 movl 12(%ebp),%eax
 cmpl -4(%ebp),%eax
 ja .L12
 movl 12(%ebp),%eax
 cmpl -4(%ebp),%eax
 jne .L13
 movl 8(%ebp),%eax
 cmpl -8(%ebp),%eax
 ja .L12
 movl 8(%ebp),%eax
 cmpl -8(%ebp),%eax
 jne .L13
 jmp .L13
 .p2align 4,,7
.L13:
 jmp .L10
 .p2align 4,,7
.L12:
 movl 16(%ebp),%eax
 movl -8(%ebp),%edx
 addl %edx,%eax
 movl 20(%ebp),%edx
 movl -8(%ebp),%ecx
 addl %ecx,%edx
 movb (%edx),%cl
 movb %cl,(%eax)
.L11:
 addl $1,-8(%ebp)
 adcl $0,-4(%ebp)
 jmp .L9
 .p2align 4,,7
.L10:
.L8:
 movl %ebp,%esp
 popl %ebp
 ret
.Lfe2:
 .size  func2,.Lfe2-func2
 .align 16
.globl main
 .type  main,@function
main:
 pushl %ebp
 movl %esp,%ebp
 subl $24,%esp
 pushl $0                            <=============
 pushl $0                            <=============    I expect 0x1
 movl -8(%ebp),%eax
 pushl %eax
 movl -4(%ebp),%eax
 pushl %eax
 call func1
 addl $16,%esp
 pushl $0                            <=============
 pushl $0                            <=============    I expect 0x1
 movl -8(%ebp),%eax
 pushl %eax
 movl -4(%ebp),%eax
 pushl %eax
 call func1
 addl $16,%esp
 movl -8(%ebp),%eax
 pushl %eax
 movl -4(%ebp),%eax
 pushl %eax
 pushl $0                            <=============
 pushl $0                            <=============    I expect 0x1
 call func2
 addl $16,%esp
 movl -8(%ebp),%eax
 pushl %eax
 movl -4(%ebp),%eax
 pushl %eax
 pushl $0                            <=============
 pushl $0                            <=============    I expect 0x1
call func2
 addl $16,%esp
.L14:
 movl %ebp,%esp
 popl %ebp
 ret
.Lfe3:
 .size  main,.Lfe3-main
 .ident "GCC: (GNU) 2.95.2 19991024 (release)"
---------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]