diff --git a/libcxx/include/__assert b/libcxx/include/__assert index 90eaa6023587b..1bfed2890b79f 100644 --- a/libcxx/include/__assert +++ b/libcxx/include/__assert @@ -20,8 +20,8 @@ #define _LIBCPP_ASSERT(expression, message) \ (__builtin_expect(static_cast(expression), 1) \ ? (void)0 \ - : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \ - expression) " failed: " message "\n")) + : _LIBCPP_ASSERTION_HANDLER( \ + __FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING(expression) " failed: " message)) // WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear // optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a diff --git a/libcxx/src/verbose_abort.cpp b/libcxx/src/verbose_abort.cpp index 94bdb451dee7a..efb7b9be6f61c 100644 --- a/libcxx/src/verbose_abort.cpp +++ b/libcxx/src/verbose_abort.cpp @@ -30,6 +30,9 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept { va_list list; va_start(list, format); std::vfprintf(stderr, format, list); + // Callers of `__libcpp_verbose_abort` do not include a newline but when + // writing the message to stderr we need to include one. + std::fputc('\n', stderr); va_end(list); } diff --git a/libcxx/test/support/check_assertion.h b/libcxx/test/support/check_assertion.h index a279400d651b4..ea04944ea9326 100644 --- a/libcxx/test/support/check_assertion.h +++ b/libcxx/test/support/check_assertion.h @@ -340,7 +340,7 @@ void std::__libcpp_verbose_abort(char const* format, ...) noexcept { std::fprintf(stderr, "%s\n", Marker); std::vfprintf(stderr, format, args); - std::fprintf(stderr, "%s", Marker); + std::fprintf(stderr, "\n%s", Marker); va_end(args);