* [committed] libstdc++: Add noexcept to __replacement_assert [PR101429]
@ 2021-07-15 15:26 Jonathan Wakely
2021-07-15 17:20 ` François Dumont
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2021-07-15 15:26 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
This results in slightly smaller code when assertions are enabled when
either using Clang (because it adds code to call std::terminate when
potentially-throwing functions are called in a noexcept function) or a
freestanding or non-verbose build (because it doesn't use printf).
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101429
* include/bits/c++config (__replacement_assert): Add noexcept.
[!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
instead of __replacement_assert.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2276 bytes --]
commit 1f7182d68c24985dace2a94422c671ff987c262c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jul 14 12:25:11 2021
libstdc++: Add noexcept to __replacement_assert [PR101429]
This results in slightly smaller code when assertions are enabled when
either using Clang (because it adds code to call std::terminate when
potentially-throwing functions are called in a noexcept function) or a
freestanding or non-verbose build (because it doesn't use printf).
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101429
* include/bits/c++config (__replacement_assert): Add noexcept.
[!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
instead of __replacement_assert.
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 9314117aed8..69ace386dd7 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -500,6 +500,7 @@ namespace std
// Assert.
#if defined(_GLIBCXX_ASSERTIONS) \
|| defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS)
+# if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE
namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
@@ -508,6 +509,7 @@ namespace std
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
+ _GLIBCXX_NOEXCEPT
{
__builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
@@ -517,10 +519,18 @@ namespace std
#define __glibcxx_assert_impl(_Condition) \
if (__builtin_expect(!bool(_Condition), false)) \
{ \
- __glibcxx_constexpr_assert(_Condition); \
+ __glibcxx_constexpr_assert(false); \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
#_Condition); \
}
+# else // ! VERBOSE
+# define __glibcxx_assert_impl(_Condition) \
+ if (__builtin_expect(!bool(_Condition), false)) \
+ { \
+ __glibcxx_constexpr_assert(false); \
+ __builtin_abort(); \
+ }
+#endif
#endif
#if defined(_GLIBCXX_ASSERTIONS)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [committed] libstdc++: Add noexcept to __replacement_assert [PR101429]
2021-07-15 15:26 [committed] libstdc++: Add noexcept to __replacement_assert [PR101429] Jonathan Wakely
@ 2021-07-15 17:20 ` François Dumont
2021-07-15 18:46 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: François Dumont @ 2021-07-15 17:20 UTC (permalink / raw)
To: Jonathan Wakely, libstdc++, gcc-patches
On 15/07/21 5:26 pm, Jonathan Wakely via Libstdc++ wrote:
> This results in slightly smaller code when assertions are enabled when
> either using Clang (because it adds code to call std::terminate when
> potentially-throwing functions are called in a noexcept function) or a
> freestanding or non-verbose build (because it doesn't use printf).
>
> Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/101429
> * include/bits/c++config (__replacement_assert): Add noexcept.
> [!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
> instead of __replacement_assert.
>
> Tested powerpc64le-linux. Committed to trunk.
>
ChangeLog is talking about __builtin_trap but there is none in the
attached patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [committed] libstdc++: Add noexcept to __replacement_assert [PR101429]
2021-07-15 17:20 ` François Dumont
@ 2021-07-15 18:46 ` Jonathan Wakely
2021-07-16 14:38 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2021-07-15 18:46 UTC (permalink / raw)
To: François Dumont; +Cc: Jonathan Wakely, libstdc++, gcc-patches
On Thu, 15 Jul 2021, 18:21 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:
> On 15/07/21 5:26 pm, Jonathan Wakely via Libstdc++ wrote:
> > This results in slightly smaller code when assertions are enabled when
> > either using Clang (because it adds code to call std::terminate when
> > potentially-throwing functions are called in a noexcept function) or a
> > freestanding or non-verbose build (because it doesn't use printf).
> >
> > Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
> >
> > libstdc++-v3/ChangeLog:
> >
> > PR libstdc++/101429
> > * include/bits/c++config (__replacement_assert): Add noexcept.
> > [!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
> > instead of __replacement_assert.
> >
> > Tested powerpc64le-linux. Committed to trunk.
> >
> ChangeLog is talking about __builtin_trap but there is none in the
> attached patch.
>
Yes I already noticed that and mentioned it in the bugzilla PR. It uses
__builtin_abort not __builtin_trap. I'll fix the ChangeLog file tomorrow
after it gets generated.
The Git commit message will stay wrong though.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [committed] libstdc++: Add noexcept to __replacement_assert [PR101429]
2021-07-15 18:46 ` Jonathan Wakely
@ 2021-07-16 14:38 ` Jonathan Wakely
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-07-16 14:38 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: François Dumont, libstdc++, gcc-patches
On Thu, 15 Jul 2021 at 19:47, Jonathan Wakely wrote:
>
>
>
> On Thu, 15 Jul 2021, 18:21 François Dumont via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
>>
>> On 15/07/21 5:26 pm, Jonathan Wakely via Libstdc++ wrote:
>> > This results in slightly smaller code when assertions are enabled when
>> > either using Clang (because it adds code to call std::terminate when
>> > potentially-throwing functions are called in a noexcept function) or a
>> > freestanding or non-verbose build (because it doesn't use printf).
>> >
>> > Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
>> >
>> > libstdc++-v3/ChangeLog:
>> >
>> > PR libstdc++/101429
>> > * include/bits/c++config (__replacement_assert): Add noexcept.
>> > [!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
>> > instead of __replacement_assert.
>> >
>> > Tested powerpc64le-linux. Committed to trunk.
>> >
>> ChangeLog is talking about __builtin_trap but there is none in the
>> attached patch.
>
>
>
> Yes I already noticed that and mentioned it in the bugzilla PR. It uses __builtin_abort not __builtin_trap. I'll fix the ChangeLog file tomorrow after it gets generated.
Fixed in r12-2361
> The Git commit message will stay wrong though.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-16 14:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 15:26 [committed] libstdc++: Add noexcept to __replacement_assert [PR101429] Jonathan Wakely
2021-07-15 17:20 ` François Dumont
2021-07-15 18:46 ` Jonathan Wakely
2021-07-16 14:38 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).