* [PATCH] PR libstdc++/88740 Print assertion messages to stderr
@ 2019-01-22 16:08 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2019-01-22 16:08 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 358 bytes --]
Messages printed to stdout might be lost when the process terminates
via abort(), because output streams aren't flushed. Write to stderr
instead (if stderr is defined by <stdio.h>).
PR libstdc++/88740
* testsuite/util/testsuite_hooks.h [stderr] (VERIFY): Use fprintf to
write to stderr instead of using printf.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1547 bytes --]
commit d249af5ee2c32453b5df5bcb1a9c645993da0673
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Jan 22 15:54:44 2019 +0000
PR libstdc++/88740 Print assertion messages to stderr
PR libstdc++/88740
* testsuite/util/testsuite_hooks.h [stderr] (VERIFY): Use fprintf to
write to stderr instead of using printf.
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index 3999a5d6ee1..51c431bf9c0 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -46,18 +46,25 @@
#include <bits/c++config.h>
#include <bits/functexcept.h>
#include <ctime>
+#include <stdio.h>
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#ifdef stderr
+# define _VERIFY_PRINT(S, F, L, P, C) __builtin_fprintf(stderr, S, F, L, P, C)
+#else
+# define _VERIFY_PRINT(S, F, L, P, C) __builtin_printf(S, F, L, P, C)
+#endif
+
#define VERIFY(fn) \
do \
{ \
if (! (fn)) \
{ \
- __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", \
- __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \
+ _VERIFY_PRINT("%s:%d: %s: Assertion '%s' failed.\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \
__builtin_abort(); \
} \
} while (false)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-22 16:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 16:08 [PATCH] PR libstdc++/88740 Print assertion messages to stderr 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).