From patchwork Wed Aug 14 17:17:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1972489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=de7ty9tS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WkZhW2yKtz1yXl for ; Thu, 15 Aug 2024 03:18:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0A773858414 for ; Wed, 14 Aug 2024 17:18:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 435563858D20 for ; Wed, 14 Aug 2024 17:17:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 435563858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 435563858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723655865; cv=none; b=OzEjCvbxK+tWf2vNPDmIv1M8Ft+udIowUilLsRx+eNc3G8I1cTHm0Fr9HU3clZtVEFgBcCHyvJdKrXXgpZ3nqWKrf3OpLWS/2HVmc0jVbqAquKc7nd+J08BH5xU3QkbAf48yzQUfcro8WzG8ZWO8oaaUBd2Dh3llw/tsTpfh8NQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723655865; c=relaxed/simple; bh=cLyU2Z+6fbMLyFQ3xMBgS45N8UAjERgCLSHJzcA9CAU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ThFmCTDTKdJEh+DW8Pbn3o+CkofwNmxXOs9OyKvsm3Q21HmDTQjFtGYw6Sz9MyZdA5nvJdwWNezcVH510a7ZJfN/jqu4Gmiau2z+W0KAcrB4rNUBmF7REvDZDDwSdrn5agYavKSUgcXea/AC4pm9NoxMJCNRv38oMvSGlI49Zmk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723655864; 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=1hz1gfRRsoEHzUad+21+Gl37BwuUf0BoCow3bCQtT9E=; b=de7ty9tSnnxkLsNRj91sXS06SqW716k7PZAA8/VJC0zrj/YVQwEtQRmAFNt5gTB3VYdt1/ QBNevAr8bbTYkwbKFcym22BkXR7ZrBdB0FTYVZHfvlwGZ5Bw/6I4bX07rCvaPBjL0/mRjB UiwrmBTO5szyn2T50A4sKjtQRXkIRhg= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-6qwbWmd2Pp6Wb25rY6EArg-1; Wed, 14 Aug 2024 13:17:42 -0400 X-MC-Unique: 6qwbWmd2Pp6Wb25rY6EArg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52efd4afebeso78601e87.2 for ; Wed, 14 Aug 2024 10:17:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723655860; x=1724260660; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1hz1gfRRsoEHzUad+21+Gl37BwuUf0BoCow3bCQtT9E=; b=UJxeK1Nm+DWJ52KfxVrCLqjBjraBW9/SjCG0RR/wUVG8om5rDauAxW3Y51AZ6tWvlk B3Fua9YI/RkVVZ+2UHx8nwiuRfbOLEXj3RElYjk+lwFYv/X313cCgEa/tq1nQaBaNFUs 0MgY/Hq3L1GLejdXvnbFeICPdCVIbcVv/6yaNXOEDZQo235QfwW+CZPLM2fF05JIxdVQ Ep3iArY1sILFcbXOpDhAFXqg7OPyppIaticXXHBc2J07WsYERmQnMQuT5L6EcWiE7LAC w7DQkw3RWGbiecVjPFabK0upA9OOlTQf1YDYZIpszBJSA4O/BGI84VxrTH1FS3TNo5vf fDOQ== X-Gm-Message-State: AOJu0YwjaS2wFISbE7YZ19SLe97jJTYiDqKPXhi5E+u8fcOkLEVI0r71 Bmc7WHXI315sXiyG3DC9oy2Q97DHRlZJOt6lsxc1j6z2kdGQBMlvr/cqWMRebMeyDtxJ0q5+IVf cq+I3z0sRqTWZxSkDtx+zgUYloyd5n8ocbA/6FvZcqBys/BB0QkN600RBKg== X-Received: by 2002:a2e:f02:0:b0:2ef:1bd5:bac3 with SMTP id 38308e7fff4ca-2f3aa1f9904mr15232701fa.41.1723655860453; Wed, 14 Aug 2024 10:17:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2cH+P4vsMEI+ORud9pJDvdQU11/lNmU0ArvVDENjh6UnFE+cpv6Ux9sYuraFwzgZUq6ALrg== X-Received: by 2002:a2e:f02:0:b0:2ef:1bd5:bac3 with SMTP id 38308e7fff4ca-2f3aa1f9904mr15232581fa.41.1723655859754; Wed, 14 Aug 2024 10:17:39 -0700 (PDT) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36e4e51eb52sm13488764f8f.74.2024.08.14.10.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 10:17:39 -0700 (PDT) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.95) (envelope-from ) id 1seHcK-00AY4Y-Cj; Wed, 14 Aug 2024 17:17:00 +0000 Date: Wed, 14 Aug 2024 17:17:00 +0000 (UTC) From: Joseph Myers To: Florian Weimer cc: libc-alpha@sourceware.org Subject: [PATCH v2] Test errno setting on strtod overflow in tst-strtod-round [committed] In-Reply-To: <87frr7mp56.fsf@oldenburg.str.redhat.com> Message-ID: <33acf265-61f7-aecb-bcd8-99a8b42d2889@redhat.com> References: <988bfab3-349b-962f-4ba2-2bcb2051f6f4@redhat.com> <87frr7mp56.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org On Wed, 14 Aug 2024, Florian Weimer wrote: > Maybe print new_errno in the error message? Rest looks okay. Committed in the following form. Test errno setting on strtod overflow in tst-strtod-round We have no tests that errno is set to ERANGE on overflow of strtod-family functions (we do have some tests for underflow, in tst-strtod-underflow). Add such tests to tst-strtod-round. Tested for x86_64. diff --git a/stdlib/tst-strtod-round-skeleton.c b/stdlib/tst-strtod-round-skeleton.c index 6fba4b5228..c3cc0201d4 100644 --- a/stdlib/tst-strtod-round-skeleton.c +++ b/stdlib/tst-strtod-round-skeleton.c @@ -21,6 +21,7 @@ declared in the headers. */ #define _LIBC_TEST 1 #define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include #include #include #include @@ -205,7 +206,9 @@ struct test { #define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \ { \ feclearexcept (FE_ALL_EXCEPT); \ + errno = 0; \ FTYPE f = STRTO (FSUF) (s, NULL); \ + int new_errno = errno; \ if (f != expected->FSUF \ || (copysign ## CSUF) (1.0 ## LSUF, f) \ != (copysign ## CSUF) (1.0 ## LSUF, expected->FSUF)) \ @@ -254,6 +257,14 @@ struct test { printf ("ignoring this exception error\n"); \ } \ } \ + if (overflow->FSUF && new_errno != ERANGE) \ + { \ + printf (FNPFXS "to" #FSUF \ + " (" STRM ") left errno == %d," \ + " not %d (ERANGE)\n", \ + s, new_errno, ERANGE); \ + result = 1; \ + } \ } \ }