From 804577075120218c2a38d457906e6a3182659e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Thu, 29 Aug 2024 10:27:04 -0300 Subject: [PATCH] libCom: don't use std::unexpected in epicsThread. Besides being deprecated in C++11 and removed in C++17, the intended use case for this was always wrong, since std::unexpected() is called by the C++ runtime when a function throws an exception that was not specified in its "dynamic exception specification", which is different from an exception thrown by user code which wasn't caught [1,2]. Using abort() keeps the same behavior, but with the intended semantics. We don't use std::abort() to simplify backwards compatibility. [1] https://github.com/epics-base/epics-base/issues/343 [2] https://en.cppreference.com/w/cpp/error/unexpected --- modules/libcom/src/osi/epicsThread.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/libcom/src/osi/epicsThread.cpp b/modules/libcom/src/osi/epicsThread.cpp index b67c8bf29..b1273fd55 100644 --- a/modules/libcom/src/osi/epicsThread.cpp +++ b/modules/libcom/src/osi/epicsThread.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -78,10 +79,8 @@ void epicsThread :: printLastChanceExceptionMessage ( "with type \"%s\" in thread \"%s\" at %s\n", pExceptionContext, pExceptionTypeName, name, date ); errlogFlush (); - // This behavior matches the C++ implementation when an exception - // isn't handled by the thread code. Users can install their own - // application-specific unexpected handler if preferred. - std::unexpected (); + + abort(); } extern "C" void epicsThreadCallEntryPoint ( void * pPvt )