From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.redhat.com (Postfix) with ESMTP id A9DCD3EB80 for ; Tue, 3 Dec 2002 02:36:21 -0500 (EST) Received: (from mail@localhost) by int-mx1.corp.redhat.com (8.11.6/8.11.6) id gB37aLr24299 for axp-list@listman.redhat.com; Tue, 3 Dec 2002 02:36:21 -0500 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id gB37aLD24295 for ; Tue, 3 Dec 2002 02:36:21 -0500 Received: from mailout01.sul.t-online.com (mailout01.sul.t-online.com [194.25.134.80]) by mx1.redhat.com (8.11.6/8.11.6) with SMTP id gB37BPP10843 for ; Tue, 3 Dec 2002 02:11:26 -0500 Received: from fwd00.sul.t-online.de by mailout01.sul.t-online.com with smtp id 18J7bQ-0004co-02; Tue, 03 Dec 2002 08:36:20 +0100 Received: from juist (520046482682-0001@[217.230.31.167]) by fmrl00.sul.t-online.com with esmtp id 18J7bF-1AK8X2C; Tue, 3 Dec 2002 08:36:09 +0100 Received: from falk by juist with local (Exim 3.36 #1 (Debian)) id 18J7bA-0002od-00 for ; Tue, 03 Dec 2002 08:36:04 +0100 X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2 From: Falk Hueffner Date: 03 Dec 2002 08:36:02 +0100 In-Reply-To: Message-ID: <87n0nn3671.fsf@student.uni-tuebingen.de> User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.5 (broccoli) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender: 520046482682-0001@t-dialin.net X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0.1 Precedence: bulk Reply-To: axp-list@redhat.com List-Help: List-Post: List-Subscribe: , List-Id: Linux and Red Hat on Alpha processors List-Unsubscribe: , List-Archive: "Andrew A. Gill" writes: > [superluser@trystero superluser]$ cat fpe.cc > #include > > int main(void) > { > int x = (int) (4/(float)0); > printf ("x = %i\n", x); > } > > [superluser@trystero superluser]$ g++ fpe.cc > fpe.cc: In function `int main()': > fpe.cc:5: warning: division by zero in `4 / 0.' > [superluser@trystero superluser]$ ./a.out > x = 0 > > This is gcc version 3.2 20021115 (Red Hat Linux 8.0 3.2-14). Should > this be normal behavior? Is this the expected output of standard > C++? It is correct. 4.9: "The behavior is undefined if the truncated value cannot be represented in the destination type." So returning 0 is correct, as would be returning 23, crashing, or formatting the hard disk. It is probably not what one would expect, though; usually on Alpha, doing calculations with magic values like NAN raises a signal. It only doesn't happen here because the compiler does constant folding on it. BTW, with g++ 3.3 (CVS) you get -1, and with cxx a floating point exception. -- Falk