From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Gary Houston Newsgroups: gmane.lisp.guile.devel Subject: gcc optimisation breaks guile floating point Date: 27 Aug 2002 22:10:25 +0100 Sender: guile-devel-admin@gnu.org Message-ID: <200208272110.OAA20247@onyx.he.net> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1030482613 2177 127.0.0.1 (27 Aug 2002 21:10:13 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 27 Aug 2002 21:10:13 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17jnbD-0000Yo-00 for ; Tue, 27 Aug 2002 23:10:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17jncR-0001Fk-00; Tue, 27 Aug 2002 17:11:23 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17jnbt-0001Dz-00 for guile-devel@gnu.org; Tue, 27 Aug 2002 17:10:49 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17jnbr-0001Dh-00 for guile-devel@gnu.org; Tue, 27 Aug 2002 17:10:48 -0400 Original-Received: from onyx.he.net ([216.218.161.2]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17jnbq-0001DV-00 for guile-devel@gnu.org; Tue, 27 Aug 2002 17:10:46 -0400 Original-Received: from onyx.he.net (onyx.he.net [216.218.161.2]) by onyx.he.net (8.8.6/8.8.2) with ESMTP id OAA20247 for ; Tue, 27 Aug 2002 14:10:49 -0700 Original-Received: (qmail 27973 invoked from network); 27 Aug 2002 21:10:25 -0000 Original-Received: from localhost (HELO x.localnet) (127.0.0.1) by localhost with SMTP; 27 Aug 2002 21:10:25 -0000 Original-To: guile-devel@gnu.org Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1170 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1170 Floating point seems somewhat broken in latest CVS if compiled with recent gcc (e.g., version 3.2): guile> 3.2 0.0 The problem is in libguile/numbers.c:scm_make_real, and only if scm_double_cell is inlined (so it isn't a problem in Guile 1.5). Compiling with the -fno-strict-aliasing option fixes it. Here's a similar kind of problem code: #include #include static void * make_z (double x) { void *z = malloc (50); memset (z, 0, 50); *((unsigned long *) z) = 0; *((double *) z) = x; return z; } main () { void *z = make_z (3.2); double d = *((double *) z); int i; for (i = 0; i < sizeof (double); i++) { printf ("%d\n", ((unsigned char *) &d)[i]); } return 0; } Apparently, "according to ANSI C" (no direct quotation available), the compiler can assume that *((unsigned long *) z) and *((double *) z) refer to different locations and reorder the statements! I don't know what would be needed to make Guile conform to such stringent interpretation of the standard, but I don't think it would be easy to determine that it was correct and that it would always stay that way. Perhaps we should just add the -fno-strict-aliasing option if the compiler supports it? _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel