{"id":2225438,"url":"http://patchwork.ozlabs.org/api/patches/2225438/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/or4il4vrsy.fsf_-_@lxoliva.fsfla.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<or4il4vrsy.fsf_-_@lxoliva.fsfla.org>","list_archive_url":null,"date":"2026-04-21T04:52:13","name":"libstdc++: follow std in numeric_limits<bool>::traps and integral traps","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"382eb44fcb09469e57a2aab2fcd93026ce8d7c95","submitter":{"id":74937,"url":"http://patchwork.ozlabs.org/api/people/74937/?format=json","name":"Alexandre Oliva","email":"oliva@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/or4il4vrsy.fsf_-_@lxoliva.fsfla.org/mbox/","series":[{"id":500726,"url":"http://patchwork.ozlabs.org/api/series/500726/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500726","date":"2026-04-21T04:52:13","name":"libstdc++: follow std in numeric_limits<bool>::traps and integral traps","version":1,"mbox":"http://patchwork.ozlabs.org/series/500726/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225438/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225438/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=F1KNBMCX;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=F1KNBMCX","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=adacore.com","sourceware.org; spf=pass smtp.mailfrom=adacore.com","server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.222.50"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g093l1VBzz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 14:53:37 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 6E2284BA9035\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 04:53:35 +0000 (GMT)","from mail-ua1-f50.google.com (mail-ua1-f50.google.com\n [209.85.222.50])\n by sourceware.org (Postfix) with ESMTPS id 343924BA9016\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 04:52:29 +0000 (GMT)","by mail-ua1-f50.google.com with SMTP id\n a1e0cc1a2514c-953ac1602f8so2905100241.1\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 21:52:29 -0700 (PDT)","from free.home ([2804:14c:4d1:41a6::2000])\n by smtp.gmail.com with ESMTPSA id\n a1e0cc1a2514c-95890bca3fdsm5686638241.10.2026.04.20.21.52.27\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 20 Apr 2026 21:52:27 -0700 (PDT)","from livre (livre.home [172.31.160.2])\n by free.home (8.15.2/8.15.2) with ESMTPS id 63L4qDQN003516\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 21 Apr 2026 01:52:14 -0300"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 6E2284BA9035","OpenDKIM Filter v2.11.0 sourceware.org 343924BA9016"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 343924BA9016","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 343924BA9016","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776747149; cv=none;\n b=Ydz2X9LFnGzwEps/rRs99YUki6OsFcJpyJarK94sLfiVzZqYsTkxFl27h8ZxVhV47UbGbWWnBRk/QkBbDkllxqvdr7+EIwD8ishPy2c4fqarJ/lGij1jYGdrXdgY9CpF9msNEVEYc35SGXT3e/pWRMyuELFlUhmOf/4TgmiE/AE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776747149; c=relaxed/simple;\n bh=y9LAQQ2oFKakwzNO3wChyWPZeIlMxu8yFjpBFgASFNw=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=xAj3pVxxDdghWNrZR5+Auy+am1R4dtfq9HE1S765esqc0dskA4r3NHlIVWpVcEGuqe5Aik47Dd2sIEaJkJjjubHrbQTtUPvM26rZTONfehdbk9zMUKVpqhlmuCaHzjsWXQ2eK/IAc8qyFfgBvOTZ8aXoO6gLBO3CXWhZCGYSJcI=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=adacore.com; s=google; t=1776747148; x=1777351948; darn=gcc.gnu.org;\n h=mime-version:user-agent:message-id:in-reply-to:date:references\n :organization:subject:cc:to:from:from:to:cc:subject:date:message-id\n :reply-to; bh=fJm6gW3rrT1hU+bSDeWy8rdL3YBvqYzwOuQZDPjCySc=;\n b=F1KNBMCX/+KpLFZma1Ikk2udUWDTO884LfyTfnydQe3w7gqci/wRZkmSNO1Ou3LZu0\n rj4dn01BibfZZJpSNrQNpegprQQwsUZghhwU3s1HLVMVe53b5HAFAbQKArc7wY7b06iE\n ZfXa7QZEg+68xjYL3u1ArvAXxMAeUGuw8v2m/wQURnzj8UjI3uRMliQCJVwmKfqrSQGa\n y1z8UXkI+AtmRZ9fo4yJ8X4R0x+IQZbho9flfeEi34QABpegN6y35FAcUvri4exJtyet\n DrTOy0c11X35XLHQrKjSt4bGoW785dwE0zcmXWBXGvCxq/sn4WIc9i+ie1hPcDCR62vP\n 7wnw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776747148; x=1777351948;\n h=mime-version:user-agent:message-id:in-reply-to:date:references\n :organization:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=fJm6gW3rrT1hU+bSDeWy8rdL3YBvqYzwOuQZDPjCySc=;\n b=EgtlVuP8PhIZ9yHiymy372FFF143exuQhZulsbKnXarvWTRKP/lXGoPa+Rf7PTwDCR\n 8JKjgPRPuY7ihoH6rDHPd9NKK3oFVktQK0bdDF16T0H3QrXshoEOcPX83MJJZzMLVAAr\n SpKI0LmEzudPmzkXa7aBDAyiW7eDyIrWFLt4OvfaEhwtlzGEcmRf6kdQXpwko+0IAkR/\n YSBzTIHw3/xC5jCggAq3iHF7B5Qpqia7RudVMika7qVBYLdiBJJWZj3Dd6iwvM1mXArF\n 1fjpT4rvWaN1ZhVfx36b3biVPtgTigvupjuG6tKmwdBYf6qcy/se1OuHPeI1P16QbHYC\n b6Jg==","X-Gm-Message-State":"AOJu0Yx/mW2tf4EvObutC7DvbUKtxZz5XGW7po2aGN2KkeeDnYGUNScM\n CaBSJIWKqgIZOnpyWEG1W3uOKms9ZD62QP5733gcsJ6BesQ76WI9ntt4CFoe1Hv3BA==","X-Gm-Gg":"AeBDietTjqPjvE2yXIElaVFonPWC2k2nFCfdhjme4SM+2oBnGV8jTj35FqDM9loPxvu\n h19COO8jSmmV289hNu808+AHRuDrnN1iQa6GoNFgdD46uGUSqK4pj7bPCTh1rs6GnMzWoIGp1j+\n uW/L4eZiyvHVn+X1NZOL/LoJUNp95BA0Koz6MxJ+euMH2h51LgYjWJkEHX3TPtkNNUQE6yUmMyr\n S1hJ8NT7GGRQGF5XDLPOsP7P8DDatC2st2ExOQzr3JHkTqeNS6rRm3CGcXm97tNaEIKHhgzYgxH\n M0PZiZoNQ3ARcI+CGCYRDNU8tAGk0trgy1ZDfHsbRxyE5JUnzUVEDKyGWCCezsFy09nba3VulnY\n l8HsG+Yc+n9FLfxFYWDtP51qwq/N7XefKWltKjqpyxGLwpEkKctbZs+VgvQe4SsCA92FbKXXVVD\n KCOoJVmfbc+g==","X-Received":"by 2002:a05:6102:148d:b0:607:9b72:28c1 with SMTP id\n ada2fe7eead31-616feb804demr6198836137.22.1776747148337;\n Mon, 20 Apr 2026 21:52:28 -0700 (PDT)","From":"Alexandre Oliva <oliva@adacore.com>","To":"Jonathan Wakely <jwakely@redhat.com>","Cc":"gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org","Subject":"[PATCH] libstdc++: follow std in numeric_limits<bool>::traps and\n integral traps","Organization":"Free thinker, does not speak for AdaCore","References":"<oro6jr10tw.fsf@lxoliva.fsfla.org>\n <CACb0b4nsiE_9CxUczx8=iHgsDgo-_-uE2P8Z8aiPMTQgu1RpZg@mail.gmail.com>","Date":"Tue, 21 Apr 2026 01:52:13 -0300","In-Reply-To":"\n <CACb0b4nsiE_9CxUczx8=iHgsDgo-_-uE2P8Z8aiPMTQgu1RpZg@mail.gmail.com>\n (Jonathan Wakely's message of \"Mon, 13 Apr 2026 10:25:39 +0100\")","Message-ID":"<or4il4vrsy.fsf_-_@lxoliva.fsfla.org>","User-Agent":"Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)","MIME-Version":"1.0","Content-Type":"text/plain","X-Scanned-By":"MIMEDefang 2.84","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"On Apr 13, 2026, Jonathan Wakely <jwakely@redhat.com> wrote:\n\n> So I think the correct fix is to just get rid of\n> __glibcxx_integral_traps and set numeric_limits::traps to false for\n> all integral types. But that's definitely stage 1 material.\n\nI couldn't get myself to pull the trigger :-) but I've tested this:\n\n\nThere's a comment from 2002 suggesting that\nnumeric_limits<bool>::traps was in a DR, but C++ standards including\n11, 17 and 23 explicitly set it to false, presumably in response to\nissue 184.\n\nIssue 554 clarifies that traps is about values that may trap, rather\nthan operations that may trap, so we were wrong in the interpretation\nabout divide-by-zero operations' trapping on integral types that led\nto __glibcxx_integral_traps's defaulting to true, and some of its\noverrides.\n\nAlign numeric_limits<bool>::traps with the standard, default\n__glibcxx_integral_traps to false, drop the overriders based on the\nincorrect interpretation, but keep __glibcxx_integral_traps for the\nadmittedly unlikely case of trapping integral values' existing on some\narchitecture.\n\n\nRegstrapped on x86_64-linux-gnu.  Also tested on arm-eabi and\nriscv32-elf.  Ok for stage1?\n\n(should the otherwise-effectively-empty cpu_defines.h headers be deleted\naltogether?)\n\n\nfor  libstdc++-v3/ChangeLog\n\n\t* include/std/limits (__glibcxx_integral_traps): Set to\n\tfalse.  Update comments.\n\t(numeric_limits<bool>::traps): Likewise.  Likewise.\n\t* config/cpu/arm/cpu_defines.h (__glibcxx_integral_traps):\n\tDrop overrider.\n\t* config/cpu/powerpc/cpu_defines.h (__glibcxx_integral_traps):\n\tLikewise.\n---\n libstdc++-v3/config/cpu/arm/cpu_defines.h     |    7 -------\n libstdc++-v3/config/cpu/powerpc/cpu_defines.h |    3 ---\n libstdc++-v3/include/std/limits               |   16 +++++++++-------\n 3 files changed, 9 insertions(+), 17 deletions(-)","diff":"diff --git a/libstdc++-v3/config/cpu/arm/cpu_defines.h b/libstdc++-v3/config/cpu/arm/cpu_defines.h\nindex 57e4cbbe0136b..36d6ab25bdb90 100644\n--- a/libstdc++-v3/config/cpu/arm/cpu_defines.h\n+++ b/libstdc++-v3/config/cpu/arm/cpu_defines.h\n@@ -30,11 +30,4 @@\n #ifndef _GLIBCXX_CPU_DEFINES\n #define _GLIBCXX_CPU_DEFINES 1\n \n-// Integer divide instructions don't trap on ARM.\n-#ifdef __ARM_ARCH_EXT_IDIV__\n-#define __glibcxx_integral_traps false\n-#else\n-#define __glibcxx_integral_traps true\n-#endif\n-\n #endif\ndiff --git a/libstdc++-v3/config/cpu/powerpc/cpu_defines.h b/libstdc++-v3/config/cpu/powerpc/cpu_defines.h\nindex f4248e0f602a3..59a9b92098726 100644\n--- a/libstdc++-v3/config/cpu/powerpc/cpu_defines.h\n+++ b/libstdc++-v3/config/cpu/powerpc/cpu_defines.h\n@@ -30,7 +30,4 @@\n #ifndef _GLIBCXX_CPU_DEFINES\n #define _GLIBCXX_CPU_DEFINES 1\n \n-// Integer divide instructions don't trap on PowerPC.\n-#define __glibcxx_integral_traps false\n-\n #endif\ndiff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits\nindex f0ba2851a0a2e..cb775fbd438e5 100644\n--- a/libstdc++-v3/include/std/limits\n+++ b/libstdc++-v3/include/std/limits\n@@ -81,10 +81,11 @@\n // The default values are appropriate for many 32-bit targets.\n \n // GCC only intrinsically supports modulo integral types.  The only remaining\n-// integral exceptional values is division by zero.  Only targets that do not\n-// signal division by zero in some \"hard to ignore\" way should use false.\n+// integral exceptional values is division by zero, but that's an operation,\n+// not a value, and traps is about values that trap (Issue554), so there aren't\n+// any for integral types.\n #ifndef __glibcxx_integral_traps\n-# define __glibcxx_integral_traps true\n+# define __glibcxx_integral_traps false\n #endif\n \n // float\n@@ -446,10 +447,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;\n       static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;\n \n-      // It is not clear what it means for a boolean type to trap.\n-      // This is a DR on the LWG issue list.  Here, I use integer\n-      // promotion semantics.\n-      static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;\n+      // The standard is explicit in that the bool specialization has it set to\n+      // false, whereas other integral types, for which no explicit\n+      // specialization is given in the standard, follow the general\n+      // specification.\n+      static _GLIBCXX_USE_CONSTEXPR bool traps = false;\n       static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;\n       static _GLIBCXX_USE_CONSTEXPR float_round_style round_style\n        = round_toward_zero;\n","prefixes":[]}