delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/03/09:28:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <42023446.7020400@edg.com>
Date: Thu, 03 Feb 2005 09:25:10 -0500
From: "William M. (Mike) Miller" <wmm AT edg DOT com>
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Wrong results from isfinite with gcc 3.4.1
References: <42013E8B DOT 7050509 AT world DOT std DOT com>
In-Reply-To: <42013E8B.7050509@world.std.com>
X-IsSubscribed: yes

William M. (Mike) Miller wrote:

> The definitions of isfinite() (and fpclassify(), on which isfinite() 
> depends) from math.h are as follows:
> 
>> #define fpclassify(x) \
>>           (__extension__ ({__typeof__(x) __x = (x); \
>>                            (sizeof (__x) == sizeof (float))  ? 
>> __fpclassifyf(__x) : __fpclassifyd(__x);}))
>>
>> #define isfinite(x) \
>>           (__extension__ ({__typeof__(x) __x = (x); \
>>                            fpclassify(__x) != FP_INFINITE && 
>> fpclassify(__x) != FP_NAN;}))

In case anyone else is interested, Andrew Pinski on the newlib 
list came up with the diagnosis.  The definition of isfinite() 
declares a local variable, __x, for the floating point value 
being examined and passes that in the call to the macro 
fpclassify().  fpclassify() declares its own local variable, __x, 
and initializes it with the macro argument.  The expansion of 
this declaration in fpclassify() shows exactly what is going wrong:

     __typeof__(__x) __x = (__x);

In other words, fpclassify()'s __x is initialized to its own 
uninitialized value, not to the value passed to isfinite().

Presumably a fix will trickle down eventually.  In the meantime, 
it's easy to fix locally if anyone else runs into the problem.

-- 
William M. (Mike) Miller | Edison Design Group, Inc.
wmm AT edg DOT com


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019