From owner-freebsd-current Fri Oct 11 15:11:38 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id PAA29397 for current-outgoing; Fri, 11 Oct 1996 15:11:38 -0700 (PDT) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id PAA29387 for ; Fri, 11 Oct 1996 15:11:33 -0700 (PDT) Received: from current1.whistle.com (current1.whistle.com [207.76.205.22]) by alpo.whistle.com (8.7.6/8.7.3) with SMTP id PAA03455; Fri, 11 Oct 1996 15:08:48 -0700 (PDT) Message-ID: <325EC4F5.167EB0E7@whistle.com> Date: Fri, 11 Oct 1996 15:06:45 -0700 From: Julian Elischer Organization: Whistle Communications X-Mailer: Mozilla 3.0b6 (X11; I; FreeBSD 2.2-CURRENT i386) MIME-Version: 1.0 To: Philippe Charnier CC: current@FreeBSD.org Subject: Re: gcc's bug. please comment References: <199610111905.VAA01615@xp11.frmug.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Philippe Charnier wrote: > > 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: This is not a bug. the C standard specifically does not define the order of evaluation in arguments to a function. for eas of programming, they are usually eveluated from right to left, (giving 2 1) but sometimes they are evaluated left to right. arguments to a function are NOT THE SAME as a coma separated list of statements, which are DEFINED to evaluate from left to right. Thus is is not goo dC to do operations on function arguments that have side-effects as the order of evaluation can vary. > fic=fopen("mypb2.csv","r"); > fscanf(fic, "%d;%d", &a[1][i++], &a[1][i++]); this will assign a[1][1] before filling out a[1][0] The reasoning was that by the time this became a noticed problem there were already too many machines doing it each way. julian