delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:reply-to:subject:to:references:from:message-id | |
:date:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; q=dns; s=default; b=ftQYH+yBpSsMFVH8 | |
4Uat+WdWHmSTYtofWpxdX4fAxqhH0/i3YCEXxLpvNUNRtrYuRuliFYu1f+7fC7kI | |
D1yOtWvGaG3gf6yrlv4vfmQjszDu7rL6daK3oYH3+QmhiV3MOJnmXC+Di3PUr5y7 | |
Yzv9X11zr4tAtukr++qTWv/HPoE= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:reply-to:subject:to:references:from:message-id | |
:date:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; s=default; bh=2XoTl0/R6aVfAp9E9dRXK/ | |
8FEWo=; b=H6x7lzJLAysHk4H8xpKrmNYVYuqXBel6UBJf+VO6ZV9Ux97HxWk8bW | |
YECJfMLY1HKrvMtbprAESLkheFM+KBK+O97Qfrr3Tj8HblA5ivDUeNfCQj05faVQ | |
S+UnX26ijLQOArKtzNNR0Vkgo/pdFWq0IcClCl1HmewC4ePjbnRxU= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
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 |
Authentication-Results: | sourceware.org; auth=none |
X-Spam-SWARE-Status: | No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Bottom, H*r:sk:smtp-ou, wish |
X-HELO: | smtp-out-so.shaw.ca |
Reply-To: | Brian DOT Inglis AT SystematicSw DOT ab DOT ca |
Subject: | Re: FPE in localtime.cc |
To: | cygwin AT cygwin DOT com |
References: | <CY4PR09MB1302CB30716988BB7BB61EF3A5440 AT CY4PR09MB1302 DOT namprd09 DOT prod DOT outlook DOT com> <20180709164947 DOT GE27673 AT calimero DOT vinschen DOT de> |
From: | Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca> |
Openpgp: | preference=signencrypt |
Message-ID: | <cf7088aa-9cb5-bc43-1bf2-6acc0603b57b@SystematicSw.ab.ca> |
Date: | Mon, 9 Jul 2018 11:16:37 -0600 |
User-Agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 |
MIME-Version: | 1.0 |
In-Reply-To: | <20180709164947.GE27673@calimero.vinschen.de> |
X-IsSubscribed: | yes |
On 2018-07-09 10:49, Corinna Vinschen wrote: > On Jul 9 15:47, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote: >> Hello, >> >> the following sample coredumps with FPE at localhost.cc:1962 with the latest snapshot (6/29/2018): ... > You can simplify your testcase by not calling any time functions: > > #define _GNU_SOURCE > #include <fenv.h> > #include <stdio.h> > #include <stdlib.h> > > #define SECSPERDAY 86400 > > int main(int argc, char **argv) > { > feenableexcept(FE_ALL_EXCEPT); > long tdays = argc > 1 ? strtol (argv[1], NULL, 10) : 189; > long seconds = tdays * SECSPERDAY + 0.5; > printf ("%ld\n", seconds); > } > > This generates a SIGFPE on Linux as well. > > The line computing seconds is the same line as used by the localtime > function. Cygwin shares the entire localtime code with the various > BSDs, so I guess they would have the same problem. What is that line meant to do? Am I missing something? It should be the equivalent of (tdays*SECSPERDAY*2 + 1)/2! It converts an integer value to double, adds 1/2, and throws it away on conversion back, unless the intermediate has insufficient mantissa bits, in which case, it loses the low bits? > Bottom line is, don't bulk enable FP exceptions, but only if you really > need it for certain parts of your code. Don't expect library functions > to be SIGFPE clean under all circumstances. Maybe selectively enable specific FPEs to check for where needed. Or be careful what you wish for, as you just might get a lot more than you bargained for ;^> -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |