From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 57238396E05B for ; Wed, 7 Jul 2021 17:22:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57238396E05B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625678574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=imCMAVf9DHS4se/FrHyUmw8yQYLaaC2geMTNwy9JsMQ=; b=hKJ9zvxvpNZvPoCZ/V7NC0IDkqGvlX9C/E/AytnG2Wxljl3hYb/iOLywQL74kx2Dw+47eq zFeQz46oYDGNATkMsLKiiz5XADT7lo9jI0I0PMBFN9YEHnKhefGtihZbkIgncHQJduOvUH ytV6C+oXmWxXQjkSkdQbnVxc5D5wA/M= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-oIA61kiAM42qIRcaKQ4UrQ-1; Wed, 07 Jul 2021 13:22:52 -0400 X-MC-Unique: oIA61kiAM42qIRcaKQ4UrQ-1 Received: by mail-pf1-f200.google.com with SMTP id y1-20020a056a001801b029031e97eab9e5so1969807pfa.7 for ; Wed, 07 Jul 2021 10:22:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=imCMAVf9DHS4se/FrHyUmw8yQYLaaC2geMTNwy9JsMQ=; b=DxfAXH4KqUBOexXX4+hMRLoYlq7gy3PTL5l4UCw4Dp3eVmk0HLCHxMNHmnen74MvoY WaZvmCqb6hLcxlKcwzxw4UQCxVhHQXVbnWpJ+ptbbYAc0muHzH7GHStu04abFacHSLVV WpOzPEthgbTdl79i34a7hybXnvAXb54aeMXUDAahgq5s7iWfOFhNJSdE0Nwg+CmRe2TY 0K5Z+DvfNA4HPX72qMi/yBC/xhBq5D8KYalLCxbuzTgVQumiUAu8b5ypyhFAOKvXwH7v 8TV5st2GrE4yJtbQQIb5cP1RBmXD/TtuDREQFp2SzXdZZo6JfTJ1MHcwRjwQNRwLsLEp wUwg== X-Gm-Message-State: AOAM532Jk4QFVJtPL2Px/9Ng69Eh7B/kz2NmH9foKgFxgcYQVOO6R2u6 9avmtxX1nfLF3TtAGt0CZ1sH8PvADIZfwZgfOMInLfIUwcVuumAXV1lNEAYBdPli+K+yDbT4bTT O6kQQD8ga4VWBO3vbzk8GtoTlR/kbFmU= X-Received: by 2002:a63:f916:: with SMTP id h22mr27272270pgi.6.1625678570622; Wed, 07 Jul 2021 10:22:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMkZNd8aagUOqwiQPhCXQa0PN6veuBg+ZuKrvYL+gNDdCeFn/A5Ctt9k1xUMHfTzT3dYjWZ51nqyzGuOT+d3c= X-Received: by 2002:a63:f916:: with SMTP id h22mr27272255pgi.6.1625678570398; Wed, 07 Jul 2021 10:22:50 -0700 (PDT) MIME-Version: 1.0 References: <878s31pz7i.fsf@keithp.com> In-Reply-To: <878s31pz7i.fsf@keithp.com> From: Jeff Johnston Date: Wed, 7 Jul 2021 13:22:39 -0400 Message-ID: Subject: Re: [PATCH] stdlib: Make strtod/strtof set ERANGE consistently for underflow. To: Keith Packard Cc: "newlib@sourceware.org" Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jjohnstn@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 17:22:55 -0000 Hi Keith, Thanks for the patch. I have pushed it to master. -- Jeff J. On Tue, Jun 22, 2021 at 1:49 PM Keith Packard wrote: > > (I suspect this patch is incomplete, but it covers all of the test cases > I've got. Help identifying additional places where this bug might exist > would be greatly appreciated) > > The C standard says that errno may acquire the value ERANGE if the > result from strtod underflows. According to IEEE 754, underflow occurs > whenever the value cannot be represented in normalized form. > > Newlib is inconsistent in this, setting errno to ERANGE only if the > value underflows to zero, but not for denorm values, and never for hex > format floats. > > This patch attempts to consistently set errno to ERANGE for all > 'underflow' conditions, which is to say all values which are not > exactly zero and which cannot be represented in normalized form. > > This matches glibc behavior, as well as the Linux, Mac OS X, OpenBSD, > FreeBSD and SunOS strtod man pages. > > > -- > -keith >