mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libstdc++: follow std in numeric_limits<bool>::traps and integral traps
There's a comment from 2002 suggesting that numeric_limits<bool>::traps was in a DR, but C++ standards including 11, 17 and 23 explicitly set it to false, presumably in response to issue 184. Issue 554 clarifies that traps is about values that may trap, rather than operations that may trap, so we were wrong in the interpretation about divide-by-zero operations' trapping on integral types that led to __glibcxx_integral_traps's defaulting to true, and some of its overrides. Align numeric_limits<bool>::traps with the standard, default __glibcxx_integral_traps to false, drop the overriders based on the incorrect interpretation, but keep __glibcxx_integral_traps to allow command-line restoring of this ABI fix, and for the admittedly unlikely case of trapping integral values' coming to exist on some architecture. for libstdc++-v3/ChangeLog * include/std/limits (__glibcxx_integral_traps): Set to false. Update comments. (numeric_limits<bool>::traps): Drop comments. * config/cpu/arm/cpu_defines.h: Remove. * config/cpu/powerpc/cpu_defines.h: Likewise. * configure.host (cpu_defines_dir): Adjust.
This commit is contained in:
committed by
Alexandre Oliva
parent
7596229507
commit
eb829c6789
@@ -1,40 +0,0 @@
|
||||
// Specific definitions for generic platforms -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2015-2026 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file bits/cpu_defines.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* Do not attempt to use it directly. @headername{iosfwd}
|
||||
*/
|
||||
|
||||
#ifndef _GLIBCXX_CPU_DEFINES
|
||||
#define _GLIBCXX_CPU_DEFINES 1
|
||||
|
||||
// Integer divide instructions don't trap on ARM.
|
||||
#ifdef __ARM_ARCH_EXT_IDIV__
|
||||
#define __glibcxx_integral_traps false
|
||||
#else
|
||||
#define __glibcxx_integral_traps true
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
// Specific definitions for generic platforms -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2026 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file bits/cpu_defines.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* Do not attempt to use it directly. @headername{iosfwd}
|
||||
*/
|
||||
|
||||
#ifndef _GLIBCXX_CPU_DEFINES
|
||||
#define _GLIBCXX_CPU_DEFINES 1
|
||||
|
||||
// Integer divide instructions don't trap on PowerPC.
|
||||
#define __glibcxx_integral_traps false
|
||||
|
||||
#endif
|
||||
@@ -150,15 +150,9 @@ case "${host_cpu}" in
|
||||
amdgcn)
|
||||
cpu_defines_dir=cpu/gcn
|
||||
;;
|
||||
arm*)
|
||||
cpu_defines_dir=cpu/arm
|
||||
;;
|
||||
nvptx)
|
||||
cpu_defines_dir=cpu/nvptx
|
||||
;;
|
||||
powerpc* | rs6000)
|
||||
cpu_defines_dir=cpu/powerpc
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
@@ -81,10 +81,15 @@
|
||||
// The default values are appropriate for many 32-bit targets.
|
||||
|
||||
// GCC only intrinsically supports modulo integral types. The only remaining
|
||||
// integral exceptional values is division by zero. Only targets that do not
|
||||
// signal division by zero in some "hard to ignore" way should use false.
|
||||
// integral exceptional values is division by zero, but that's an operation,
|
||||
// not a value, and traps is about values that trap (Issue554), so there aren't
|
||||
// any for integral types. The standard has numeric_limits<bool>::traps
|
||||
// explicitly set to false. However, we used to set them all to true based on
|
||||
// the division-by-zero misinterpretation, so we retain this macro, and those
|
||||
// who relied on the misinterpretation can restore it with a command-line
|
||||
// define and revert the ABI-changing effects of this fix.
|
||||
#ifndef __glibcxx_integral_traps
|
||||
# define __glibcxx_integral_traps true
|
||||
# define __glibcxx_integral_traps false
|
||||
#endif
|
||||
|
||||
// float
|
||||
@@ -446,9 +451,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
|
||||
static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
|
||||
|
||||
// It is not clear what it means for a boolean type to trap.
|
||||
// This is a DR on the LWG issue list. Here, I use integer
|
||||
// promotion semantics.
|
||||
static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
|
||||
static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
|
||||
static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
|
||||
|
||||
Reference in New Issue
Block a user