From owner-freebsd-current Fri Oct 11 14:30:25 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA26733 for current-outgoing; Fri, 11 Oct 1996 14:30:25 -0700 (PDT) Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA26716 for ; Fri, 11 Oct 1996 14:30:18 -0700 (PDT) Received: (from uucp@localhost) by frmug.org (8.6.8/8.6.9) with UUCP id XAA05133 for current@FreeBSD.org; Fri, 11 Oct 1996 23:30:06 +0200 Received: from localhost (localhost [127.0.0.1]) by xp11.frmug.org (8.7.6/8.7.3/xp11-uucp-1.1) with ESMTP id VAA01615 for ; Fri, 11 Oct 1996 21:05:38 +0200 (MET DST) Message-Id: <199610111905.VAA01615@xp11.frmug.org> To: current@FreeBSD.org Subject: gcc's bug. please comment Date: Fri, 11 Oct 1996 21:05:36 +0200 From: "Philippe Charnier" Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Hello, A friend found a bug in gcc-2.7.2.1. The following program fails on i386 architecture (both FreeBSD and solaris-x86) and works as expected on sparc (both sunos and solaris2.5.1) and on hp (hp-ux9.07). As I'm not on the gcc-bug list, please comment before I report the bug. This afternoon I sent a bug report to Sun but it was before trying on FreeBSD. The output should be `1 2' but it is `2 1' on i386 computers. Here is the code: ----------mypb2.c----------------- #include #include main() { FILE *fic; int a[2][50], i = 0; fic=fopen("mypb2.csv","r"); fscanf(fic, "%d;%d", &a[1][i++], &a[1][i++]); i = 0; while (i < 2) printf("%d ", a[1][i++]); printf("\n"); fclose(fic); } ---------------------------------- ---------------mypb2.csv---------- 1;2 ---------------------------------- For those that do not have a solaris-2.5 box to test on, here is the assembly output of the compiler. .file "mypb2.c" .version "01.01" gcc2_compiled.: .section .rodata .LC0: .string "r" .LC1: .string "mypb2.csv" .LC2: .string "%d;%d" .LC3: .string "%d " .LC4: .string "\n" .text .align 4 .globl main .type main,@function main: pushl %ebp movl %esp,%ebp subl $408,%esp movl $0,-408(%ebp) pushl $.LC0 pushl $.LC1 call fopen addl $8,%esp movl %eax,%eax movl %eax,-4(%ebp) leal -404(%ebp),%eax movl -408(%ebp),%edx movl %edx,%ecx leal 0(,%ecx,4),%edx leal 200(%edx),%ecx addl %ecx,%eax pushl %eax incl -408(%ebp) leal -404(%ebp),%eax movl -408(%ebp),%edx movl %edx,%ecx leal 0(,%ecx,4),%edx leal 200(%edx),%ecx addl %ecx,%eax pushl %eax incl -408(%ebp) pushl $.LC2 movl -4(%ebp),%eax pushl %eax call fscanf addl $16,%esp movl $0,-408(%ebp) .L2: cmpl $1,-408(%ebp) jle .L4 jmp .L3 .align 4 .L4: movl -408(%ebp),%eax movl -204(%ebp,%eax,4),%edx pushl %edx incl -408(%ebp) pushl $.LC3 call printf addl $8,%esp jmp .L2 .align 4 .L3: pushl $.LC4 call printf addl $4,%esp movl -4(%ebp),%eax pushl %eax call fclose addl $4,%esp .L1: leave ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 2.7.2.1" ------ ------ Philippe Charnier charnier@lirmm.fr (smtp) charnier@xp11.frmug.org (uucp) ``a PC not running FreeBSD is like a venusian with no tentacles'' ------------------------------------------------------------------------