delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/12/12/01:38:58

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:from:to:subject:date:message-id:mime-version
:content-transfer-encoding:content-type; q=dns; s=default; b=hDN
59fP43Alp2nHUv4/xLrwVM+7idlC1U2CQDZSLiRFQL0SIDQzLdxwctUPCqiGE18M
luu7pk7gf8PNSIq0zvmXK/pYXxNtue69vM4x5ydd+0K7uEd1xOVDbYjS7svnTPmy
ASck0ZjtoRP/GtWNo7y/hppvAZos4D7/IEy2xbJY=
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:from:to:subject:date:message-id:mime-version
:content-transfer-encoding:content-type; s=default; bh=MW1AlYe2e
9xBIgDege5wq4pJLUg=; b=oQf1RAznek/tDJAdvqYlgaY3N1OVlTWJH8a5TpjVP
vd5FaHYWkbagInI7IgslCJGg4QfRphUf4jxn8yhaeUcAF+ipxGnNt0fKFhkw4Vhs
BBTbvjh1u0XCy3hDMJgF41HIY7QU2I9IbgLeggudppzB/d0UgqdAbf31Xan34KlW
QM=
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.1 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=no version=3.3.1 spammy=strtod
X-HELO: mo4-p00-ob.smtp.rzone.de
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1576132683; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=akSN2NMqjXsENeEsQWW6UG0z75tlCW8QahU4HciBprE=; b=TXEgo/9Sq15KwUq+RJaxUiXc8adtkBsiCiM84lyaXFNTxJI9x401aSN0vfHoxqQ2yH R098WAc7Pjg+yvdN1wZnEXlD5/k1yQWIleOFzx3NTvhXKip11/N6znSCxgtn/M11qv3s 8LG8qzFfuGNx9yDE4E5ZkYfuYzA4F3qA8Mx8eGWzc8KVvUKmkmhj/Mwg1ZFhOdfas7qV R4TJOfgUJ9trSiYkebzKHeTS8V3hxJI3SIo1/D5QfubddxQEAjGFprhLqk2MwbOyd1IJ xFczdXUtvjz8niTlIwq4/U5nAFPC0WBuMRbgTcdLUSt+mQW50FjkUHsPQDdGGMXBl+7/ qXlQ==
From: Bruno Haible <bruno AT clisp DOT org>
To: cygwin AT cygwin DOT com
Subject: strtold does not set errno when it should
Date: Thu, 12 Dec 2019 07:38:02 +0100
Message-ID: <3561570.L6m47ClBex@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )
MIME-Version: 1.0

POSIX [1] makes it clear that when the value to be returned would cause
underflow, it should set errno to ERANGE.

[1] <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html>

This test case fails with error code 4 on Cygwin 2.9.

========================== foo.c ==========================
#include <stdlib.h>
#include <errno.h>
#include <float.h>
#include <math.h>

int main ()
{
  const char input[] = "1E-100000";
  char *ptr;
  long double result;
  errno = 0;
  result = strtold (input, &ptr);
  if (!(ptr == input + 9))
    return 1;
  if (!(0.0L <= result && result <= LDBL_MIN))
    return 2;
  if (signbit (result))
    return 3;
  if (result == 0.0L && errno != ERANGE)
    return 4;
  return 0;
}
============================================================
$ gcc -Wall foo.c
$ ./a.exe
$ echo $?
4

The corresponding test case for strtod() / 'double' succeeds.

Bruno


--
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

- Raw text -


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