Skip to content

Commit a5b71cd

Browse files
committed
[#1384] Preserve BSK logging C-wrapper test catch on MSVC
Route the _bskError C-wrapper test through a volatile C++ function pointer on MSVC. MSVC builds use /EHc, which allows the compiler to assume extern "C" calls do not throw; that caused the BasiliskError from _bskError to bypass the local typed catch and escape to GoogleTest even though the error message was correct. Keep the normal test path unchanged for other compilers while preserving coverage that _bskError treats preformatted text as a literal message.
1 parent 981a981 commit a5b71cd

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/architecture/utilities/tests/test_bskLogging.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ TEST(BSKLogging, cBskErrorTreatsMessageAsText)
6969
BSKLogger bskLogger;
7070

7171
try {
72+
#ifdef _MSC_VER
73+
// Keep MSVC from applying /EHc's extern "C" non-throwing assumption here.
74+
using CBskErrorCaller = void (*)(BSKLogger&, const char*);
75+
CBskErrorCaller volatile cBskErrorCaller = callCBskError;
76+
cBskErrorCaller(bskLogger, "preformatted %s message");
77+
#else
7278
callCBskError(bskLogger, "preformatted %s message");
79+
#endif
7380
} catch (const BasiliskError& error) {
7481
EXPECT_STREQ("preformatted %s message", error.what());
7582
return;

0 commit comments

Comments
 (0)