From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20762 invoked by alias); 21 Jul 2002 19:06:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20741 invoked by uid 71); 21 Jul 2002 19:06:01 -0000 Resent-Date: 21 Jul 2002 19:06:01 -0000 Resent-Message-ID: <20020721190601.20740.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, pel@ucla.edu Received: (qmail 20562 invoked by uid 61); 21 Jul 2002 19:03:44 -0000 Message-Id: <20020721190344.20561.qmail@sources.redhat.com> Date: Sun, 21 Jul 2002 12:06:00 -0000 From: pel@ucla.edu Reply-To: pel@ucla.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7369: weird results with the statement "#define PI 4.*atan(1.)" X-SW-Source: 2002-07/txt/msg00594.txt.bz2 List-Id: >Number: 7369 >Category: c++ >Synopsis: weird results with the statement "#define PI 4.*atan(1.)" >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Jul 21 12:06:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Peter Latham >Release: 2.96 >Organization: >Environment: Red Hat Linux 7.3 >Description: If PI is defined via the statement #define PI 4.*atan(1.) then 1/PI and 1/3.14159 are different. >How-To-Repeat: compile using "g++ main.c". then type "a.out", which prints PI, 1/PI and 1/3.14159. the result is 3.141593 0.196350 0.318310 If for some strange reasont the file didn't attach properly, the source code is: #include #include #define PI 4.*atan(1.) //#define PI 3.14159 void main(int argc, char** argv) { fprintf(stdout, "%f %f %f\n", PI, 1/PI, 1/3.14159); } >Fix: the workaround is to not use atan in the define statement, #define PI=3.14159 this produces the correct output. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="main.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="main.c" CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8bWF0aC5oPgoKI2RlZmluZSBQSSA0LiphdGFu KDEuKQovLyNkZWZpbmUgUEkgMy4xNDE1OQoKdm9pZCBtYWluKGludCBhcmdjLCBjaGFyKiogYXJn dikKewoJZnByaW50ZihzdGRvdXQsICIlZiAlZiAlZlxuIiwgUEksIDEvUEksIDEvMy4xNDE1OSk7 Cn0K