From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 30C273858CDA; Tue, 4 Oct 2022 14:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30C273858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664892419; bh=Cyjnl+Q5QLnFQ8aLLAVja374vg/kyjJBtWb7TTrntHA=; h=From:To:Subject:Date:From; b=ogrgh44lIhfcPl+9XYZlRueKEySlTtWpzMggMCUsEU4eS+LLFRTcd1vLO8sYsUFjM r5NXOIQELmMHdabukFrJb6j6GADcV5wLFzGGoyCWv8yDaben6S67H2cpVxZ40PPnjb 6Ru/mgHAV6in+D8uq1AXQa/4PWXdoFLwia1MOLI4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-3058] libstdc++: Define functions for freestanding [PR107135] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 147f6ed39f66a3812a27d0ecd154c8efc1918688 X-Git-Newrev: 7d8189882fc89f6f410fc9bcf0f8226787316f83 Message-Id: <20221004140659.30C273858CDA@sourceware.org> Date: Tue, 4 Oct 2022 14:06:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7d8189882fc89f6f410fc9bcf0f8226787316f83 commit r13-3058-g7d8189882fc89f6f410fc9bcf0f8226787316f83 Author: Jonathan Wakely Date: Mon Oct 3 20:53:35 2022 +0100 libstdc++: Define functions for freestanding [PR107135] We don't compile src/c++11/functexcept.cc for freestanding, so just define the functions used by freestanding entities as inline calls to std::terminate. libstdc++-v3/ChangeLog: PR libstdc++/107135 * include/bits/functexcept.h [!_GLIBCXX_HOSTED] (__throw_invalid_argument, __throw_out_of_range) (__throw_out_of_range_fmt, __throw_runtime_error) (__throw_overflow_error): Define inline. * include/std/bitset (_M_copy_from_ptr) [!_GLIBCXX_HOSTED]: Replace __builtin_abort with __throw_invalid_argument. Diff: --- libstdc++-v3/include/bits/functexcept.h | 25 +++++++++++++++++++++++++ libstdc++-v3/include/std/bitset | 8 +------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/bits/functexcept.h b/libstdc++-v3/include/bits/functexcept.h index a78a17b2e04..7fad4b13316 100644 --- a/libstdc++-v3/include/bits/functexcept.h +++ b/libstdc++-v3/include/bits/functexcept.h @@ -43,6 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if _GLIBCXX_HOSTED // Helper for exception objects in void __throw_bad_exception(void) __attribute__((__noreturn__)); @@ -112,6 +113,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void __throw_bad_function_call() __attribute__((__noreturn__)); +#else // ! HOSTED + + __attribute__((__noreturn__)) inline void + __throw_invalid_argument(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_out_of_range(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_out_of_range_fmt(const char*, ...) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_runtime_error(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_overflow_error(const char*) + { std::__terminate(); } + +#endif // HOSTED + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index afabeb4ba01..1f3f68fefce 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -1514,13 +1514,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER else if (_Traits::eq(__c, __one)) _Unchecked_set(__i - 1); else - { -#if _GLIBCXX_HOSTED - __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); -#else - __builtin_abort(); -#endif - } + __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); } }