Skip to content

[libc++] Remove trailing newline from _LIBCPP_ASSERTION_HANDLER calls #143573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libcxx/include/__assert
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#define _LIBCPP_ASSERT(expression, message) \
(__builtin_expect(static_cast<bool>(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
Expand Down
3 changes: 3 additions & 0 deletions libcxx/src/verbose_abort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/support/check_assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading