[{"id":3680371,"web_url":"http://patchwork.ozlabs.org/comment/3680371/","msgid":"<CACb0b4nVthXcRNACQHN6GniQUVmCbA64prcDnGFGciPhfSX0Cg@mail.gmail.com>","list_archive_url":null,"date":"2026-04-22T09:23:02","subject":"Re: [PATCH v2] libstdc++: follow std in numeric_limits<bool>::traps\n and integral traps","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On Wed, 22 Apr 2026 at 07:12, Alexandre Oliva <oliva@adacore.com> wrote:\n>\n> On Apr 21, 2026, Jonathan Wakely <jwakely@redhat.com> wrote:\n>\n> > This is strictly speaking an ABI change for most targets, but I doubt\n> > anybody cares about numeric_limits<integral-type>::traps. I hope\n> > nobody is depending on it for anything.\n>\n> > Anybody who needs the old behaviour can compile with\n> > -D__glibcxx_integral_traps=1 if they really need it, so I think this\n> > is OK to fix ion stage 1.\n>\n> Given the ABI change argument, I decided to revert the bool\n> specialization to use the macro, so that -D__glibcxx_integral_traps=1\n> fully restores the earlier ABI properties.\n>\n> >> (should the otherwise-effectively-empty cpu_defines.h headers be deleted\n> >> altogether?)\n>\n> > I had to look into that, but it looks like we don't bother having an\n> > empty cpu_defines.h, and just use the default generic/cpu_defines.h\n> > file. So I think yes, they should be removed.\n>\n> ACK\n>\n> > I don't think we need such a detailed comment here (especially not\n> > referring to non-bool specializations).\n>\n> > We already have this comment above the whole explicit specialization,\n> > which justifies why it's there and what all its values are:\n>\n> >   // _GLIBCXX_RESOLVE_LIB_DEFECTS\n> >   // 184. numeric_limits<bool> wording problems\n>\n> > So I would just remove the comment on traps entirely.\n>\n> Fair enough.  I tweaked the opening comment, and dropped the one next to\n> the specialization.  Here's what I've just regstrapped on\n> x86_64-linux-gnu and powerpc64le-linux-gnu.  Ok for stage1?\n\nOK for stage 1 - thanks!\n\n\n>\n>\n> There's a comment from 2002 suggesting that\n> numeric_limits<bool>::traps was in a DR, but C++ standards including\n> 11, 17 and 23 explicitly set it to false, presumably in response to\n> issue 184.\n>\n> Issue 554 clarifies that traps is about values that may trap, rather\n> than operations that may trap, so we were wrong in the interpretation\n> about divide-by-zero operations' trapping on integral types that led\n> to __glibcxx_integral_traps's defaulting to true, and some of its\n> overrides.\n>\n> Align numeric_limits<bool>::traps with the standard, default\n> __glibcxx_integral_traps to false, drop the overriders based on the\n> incorrect interpretation, but keep __glibcxx_integral_traps to allow\n> command-line restoring of this ABI fix, and for the admittedly\n> unlikely case of trapping integral values' coming to exist on some\n> architecture.\n>\n>\n> for  libstdc++-v3/ChangeLog\n>\n>         * include/std/limits (__glibcxx_integral_traps): Set to\n>         false.  Update comments.\n>         (numeric_limits<bool>::traps): Drop comments.\n>         * config/cpu/arm/cpu_defines.h: Remove.\n>         * config/cpu/powerpc/cpu_defines.h: Likewise.\n>         * configure.host (cpu_defines_dir): Adjust.\n> ---\n>  libstdc++-v3/config/cpu/arm/cpu_defines.h     |   40 -------------------------\n>  libstdc++-v3/config/cpu/powerpc/cpu_defines.h |   36 -----------------------\n>  libstdc++-v3/configure.host                   |    6 ----\n>  libstdc++-v3/include/std/limits               |   14 +++++----\n>  4 files changed, 8 insertions(+), 88 deletions(-)\n>  delete mode 100644 libstdc++-v3/config/cpu/arm/cpu_defines.h\n>  delete mode 100644 libstdc++-v3/config/cpu/powerpc/cpu_defines.h\n>\n> diff --git a/libstdc++-v3/config/cpu/arm/cpu_defines.h b/libstdc++-v3/config/cpu/arm/cpu_defines.h\n> deleted file mode 100644\n> index 57e4cbbe0136b..0000000000000\n> --- a/libstdc++-v3/config/cpu/arm/cpu_defines.h\n> +++ /dev/null\n> @@ -1,40 +0,0 @@\n> -// Specific definitions for generic platforms  -*- C++ -*-\n> -\n> -// Copyright (C) 2015-2026 Free Software Foundation, Inc.\n> -//\n> -// This file is part of the GNU ISO C++ Library.  This library is free\n> -// software; you can redistribute it and/or modify it under the\n> -// terms of the GNU General Public License as published by the\n> -// Free Software Foundation; either version 3, or (at your option)\n> -// any later version.\n> -\n> -// This library is distributed in the hope that it will be useful,\n> -// but WITHOUT ANY WARRANTY; without even the implied warranty of\n> -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n> -// GNU General Public License for more details.\n> -\n> -// Under Section 7 of GPL version 3, you are granted additional\n> -// permissions described in the GCC Runtime Library Exception, version\n> -// 3.1, as published by the Free Software Foundation.\n> -\n> -// You should have received a copy of the GNU General Public License and\n> -// a copy of the GCC Runtime Library Exception along with this program;\n> -// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n> -// <http://www.gnu.org/licenses/>.\n> -\n> -/** @file bits/cpu_defines.h\n> - *  This is an internal header file, included by other library headers.\n> - *  Do not attempt to use it directly. @headername{iosfwd}\n> - */\n> -\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\n> diff --git a/libstdc++-v3/config/cpu/powerpc/cpu_defines.h b/libstdc++-v3/config/cpu/powerpc/cpu_defines.h\n> deleted file mode 100644\n> index f4248e0f602a3..0000000000000\n> --- a/libstdc++-v3/config/cpu/powerpc/cpu_defines.h\n> +++ /dev/null\n> @@ -1,36 +0,0 @@\n> -// Specific definitions for generic platforms  -*- C++ -*-\n> -\n> -// Copyright (C) 2005-2026 Free Software Foundation, Inc.\n> -//\n> -// This file is part of the GNU ISO C++ Library.  This library is free\n> -// software; you can redistribute it and/or modify it under the\n> -// terms of the GNU General Public License as published by the\n> -// Free Software Foundation; either version 3, or (at your option)\n> -// any later version.\n> -\n> -// This library is distributed in the hope that it will be useful,\n> -// but WITHOUT ANY WARRANTY; without even the implied warranty of\n> -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n> -// GNU General Public License for more details.\n> -\n> -// Under Section 7 of GPL version 3, you are granted additional\n> -// permissions described in the GCC Runtime Library Exception, version\n> -// 3.1, as published by the Free Software Foundation.\n> -\n> -// You should have received a copy of the GNU General Public License and\n> -// a copy of the GCC Runtime Library Exception along with this program;\n> -// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n> -// <http://www.gnu.org/licenses/>.\n> -\n> -/** @file bits/cpu_defines.h\n> - *  This is an internal header file, included by other library headers.\n> - *  Do not attempt to use it directly. @headername{iosfwd}\n> - */\n> -\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\n> diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host\n> index ff97216167dec..e52a32bb4c682 100644\n> --- a/libstdc++-v3/configure.host\n> +++ b/libstdc++-v3/configure.host\n> @@ -150,15 +150,9 @@ case \"${host_cpu}\" in\n>    amdgcn)\n>      cpu_defines_dir=cpu/gcn\n>      ;;\n> -  arm*)\n> -    cpu_defines_dir=cpu/arm\n> -    ;;\n>    nvptx)\n>      cpu_defines_dir=cpu/nvptx\n>      ;;\n> -  powerpc* | rs6000)\n> -    cpu_defines_dir=cpu/powerpc\n> -    ;;\n>  esac\n>\n>\n> diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits\n> index f0ba2851a0a2e..cfdbe02c844c2 100644\n> --- a/libstdc++-v3/include/std/limits\n> +++ b/libstdc++-v3/include/std/limits\n> @@ -81,10 +81,15 @@\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.  The standard has numeric_limits<bool>::traps\n> +// explicitly set to false.  However, we used to set them all to true based on\n> +// the division-by-zero misinterpretation, so we retain this macro, and those\n> +// who relied on the misinterpretation can restore it with a command-line\n> +// define and revert the ABI-changing effects of this fix.\n>  #ifndef __glibcxx_integral_traps\n> -# define __glibcxx_integral_traps true\n> +# define __glibcxx_integral_traps false\n>  #endif\n>\n>  // float\n> @@ -446,9 +451,6 @@ _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>        static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;\n>        static _GLIBCXX_USE_CONSTEXPR float_round_style round_style\n>\n> --\n> Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/\n> Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer\n> More tolerance and less prejudice are key for inclusion and diversity.\n> Excluding neuro-others for not behaving \"\"normal\"\" is *not* inclusive!\n>","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 (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=fc+82ZjR;\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 (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=fc+82ZjR","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124"],"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 4g0v1S1zY7z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 19:24:11 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 326424BAE7D4\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 09:24:09 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 3D6AC4BAD15A\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 09:23:23 +0000 (GMT)","from mail-yx1-f70.google.com (mail-yx1-f70.google.com\n [74.125.224.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-313-dtVC-qsONVa_0JnyPZ6afA-1; Wed, 22 Apr 2026 05:23:19 -0400","by mail-yx1-f70.google.com with SMTP id\n 956f58d0204a3-651c92dd649so9822358d50.1\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 02:23:19 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 326424BAE7D4","OpenDKIM Filter v2.11.0 sourceware.org 3D6AC4BAD15A"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 3D6AC4BAD15A","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 3D6AC4BAD15A","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776849803; cv=none;\n b=GJ/tB1QTs4IChuwW24Rrd3AlDQ51luqGFfJIqNkzGIlxBJ9W/CYdgTqSiUOsG0BoqnWuzuNRdGLSmyXNxZL4Roelak7GPO6JVyvmrF3ZzEbFmMhV+CUOyNv18Fi806t6buAv/PeYKnGy/GQCaz1a8lFP7UOtwkhw6JZbQCKxsOk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776849803; c=relaxed/simple;\n bh=mlMkBnPVZnKMr5YVyKXfMQbktxa57zmJNY477pSfMkY=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=XVdvF9D6WwyMrmg3eHEaACXQ0PsJoqizw2vrJrRMUtPF0b3WAJr4VY9GPJZV87K3LdrXaTwxxXHvmNVLkzs995I4uK2A5/5Ta8ftS2SopGwL/Wuf4T5gwT6xIo7yy10HeCrTePnp9drp9BTVNI2ZDPjOWKoeBEp6mGxPcDcYADw=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776849802;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=uxQIJtCoG7WWqwevPn92NHnIDguqdxbUp/Xp2IjWxlU=;\n b=fc+82ZjRIesVxAxao5WugkYN9471eFeW0OtN1UC1QPu/2ZgW6FyTjaR7kyOZya7f5+3lLP\n 02/2E5kjkz0NHK1Ocu9guNYuNWrunnSmg5AHk7TcQ+HUhMVQnJtc5QtJX+KDkZtIrl2iB6\n 7VEl/LK7eJ8YIJPQFuvem+PGe0SSblo=","X-MC-Unique":"dtVC-qsONVa_0JnyPZ6afA-1","X-Mimecast-MFC-AGG-ID":"dtVC-qsONVa_0JnyPZ6afA_1776849799","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776849799; x=1777454599;\n h=cc:to:subject:message-id:date:from:in-reply-to:references\n :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=uxQIJtCoG7WWqwevPn92NHnIDguqdxbUp/Xp2IjWxlU=;\n b=I8lmX8DvlF/ZZU4FB6bO9zGmycu8ZCnTA6z93oqQNMblnpdB8Us8s1ZABzFQW5QEIM\n Xbs1/WlTCLR3TU+yK0a+hd1dwqcFhASMF3iTruzf3Dkr+hXBnch98upI+5minwhkFrdD\n HgzsVd0KJ9FRUvwt3n6tw6X23cCR7rl28vWwhZCBM1YHgwlI81PMaYRPGi1qE2HtBFME\n HnuJiIWeX4nTgtrm7qg2Omuyfes0gNz2HRviMUFiN7v1fITkSiIA3i+FMQCoYN8pENL8\n 8Rmh88Z7odwSQ1oQtEKphfFfBVENm/ZM3VyrJ4iSAx4gwL2vmm3A+kOahJbFizKImgoy\n 1e2g==","X-Gm-Message-State":"AOJu0YzC9S5e5tMnbkakbbYryXZ1TGBIjcv450t9ypgJS56iFezNrxcB\n pL2ds+Mk2frIhmTmAwhEchT2IMPUKbl9UG+3LcYI8iyC8Rqzk0F+jwEA+fUqmccszapE/MSj0q8\n hnBpRJITq31l/sP3d4CGr6fbWndrIbNnsmIK8iroy7YM71MtC5S3R0Af2rf2UNUU/h4C8pjJRdt\n lCva1BLlQCaPW88kuYppWJM0UGju6/+WtAfQ==","X-Gm-Gg":"AeBDieudIOfy3z+xS47MH8T83OmYZ0SDRrpLVgjbvcy2+nIOWeS5KuMseV+DeaBlZlT\n t8s7SknwWxOe8ENFl6SJfLZbk0D8SrmIK2Dt8a4SEBWs5li2Cw0v+i/Sl2Ac+XmPiegYapSSjch\n 1/mhWoT3oiARQvAST98NIPP8piYjJjLHmRHCVm3bDz7eT1Gl5Xmn6yWaJNIUCmIn3lWYFZJ8EhQ\n L3nUz8JafZjcRjPdDckkWIJLmeoDv53twQb6N0JLGnhoPesw1LbkS+P6DJqssNVjxio+APMTNTr\n +A==","X-Received":["by 2002:a53:ac48:0:b0:652:e4d7:248a with SMTP id\n 956f58d0204a3-653107f85fdmr14446947d50.7.1776849798734;\n Wed, 22 Apr 2026 02:23:18 -0700 (PDT)","by 2002:a53:ac48:0:b0:652:e4d7:248a with SMTP id\n 956f58d0204a3-653107f85fdmr14446940d50.7.1776849798241; Wed, 22 Apr 2026\n 02:23:18 -0700 (PDT)"],"MIME-Version":"1.0","References":"<oro6jr10tw.fsf@lxoliva.fsfla.org>\n <CACb0b4nsiE_9CxUczx8=iHgsDgo-_-uE2P8Z8aiPMTQgu1RpZg@mail.gmail.com>\n <or4il4vrsy.fsf_-_@lxoliva.fsfla.org>\n <CACb0b4kL84SsEQ+Ho1OVVPRRYVHc1PRK7gps-OwDbGTC_Cr4qg@mail.gmail.com>\n <or5x5jttgd.fsf_-_@lxoliva.fsfla.org>","In-Reply-To":"<or5x5jttgd.fsf_-_@lxoliva.fsfla.org>","From":"Jonathan Wakely <jwakely@redhat.com>","Date":"Wed, 22 Apr 2026 10:23:02 +0100","X-Gm-Features":"AQROBzCmMVI81kjT1dXy22_aU0qe9B7kwZH8aX1fnaez9mpv0VJHd1iG8pqn8io","Message-ID":"\n <CACb0b4nVthXcRNACQHN6GniQUVmCbA64prcDnGFGciPhfSX0Cg@mail.gmail.com>","Subject":"Re: [PATCH v2] libstdc++: follow std in numeric_limits<bool>::traps\n and integral traps","To":"Alexandre Oliva <oliva@adacore.com>","Cc":"gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"YYLtu1gmNhsbXO0SKd_80osRI8PKEbWP64Dg59n3rzI_1776849799","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","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"}}]