git: 3a5c2899fc7b - main - libcxxrt: Fix diagnostics for derived classes

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 24 Jun 2026 17:36:30 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=3a5c2899fc7bd0865b5aacccc3465e46e9bc6df3

commit 3a5c2899fc7bd0865b5aacccc3465e46e9bc6df3
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-06-24 15:06:51 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-06-24 17:36:13 +0000

    libcxxrt: Fix diagnostics for derived classes
    
    In terminate_with_diagnostics the cast_to arguments were swapped, so it
    always failed.  The diagnostic handler produced output like "Terminating
    due to uncaught exception 0x24891e08000 of type std::runtime_error".
    
    Now, e->what() will actually be included in the output, e.g.
    "Terminating due to uncaught exception 0x2bba49208000 'Model file
    doesn't exist' of type std::runtime_error".
    
    Reviewed by:    dim
    Event:          Halifax Hackathon 202606
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D57822
---
 contrib/libcxxrt/exception.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc
index 5034809a1380..883361bff084 100644
--- a/contrib/libcxxrt/exception.cc
+++ b/contrib/libcxxrt/exception.cc
@@ -344,7 +344,7 @@ static void terminate_with_diagnostics() {
 		if (throw_ti)
 		{
 			std::exception *e =
-				static_cast<std::exception*>(e_ti->cast_to(static_cast<void*>(ex+1), throw_ti));
+				static_cast<std::exception*>(throw_ti->cast_to(static_cast<void*>(ex+1), e_ti));
 			if (e)
 			{
 				fprintf(stderr, " '%s'", e->what());