From d1268ce02a21c27304e91392b2896763b3b618df Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Fri, 5 May 2023 08:36:15 -0400
Subject: [PATCH] vtkFloatingPointExceptions: use `extern "C"` for
 `signal_handler`

C++17 allows non-C functions to be put here. However, this handler is
already very suspect because it uses `cerr` which is generally very not
allowed in signal handlers (there's a lock involved somewhere and a
deadlock is going to happen if another thread is using `cerr`).

Anyways, just resolve the `bugprone-signal-handler` lint for now.
---
 Common/Core/vtkFloatingPointExceptions.cxx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Common/Core/vtkFloatingPointExceptions.cxx b/Common/Core/vtkFloatingPointExceptions.cxx
index d76768030b5..8624f31f655 100644
--- a/Common/Core/vtkFloatingPointExceptions.cxx
+++ b/Common/Core/vtkFloatingPointExceptions.cxx
@@ -19,6 +19,7 @@
 
 #if defined(VTK_USE_FENV)
 #include <csignal>
+#include <cstdio>
 #include <fenv.h>
 #endif
 
@@ -33,9 +34,10 @@
 namespace
 {
 
-void signal_handler(int signal)
+extern "C" void signal_handler(int signal)
 {
-  cerr << "Error: Floating point exception detected. Signal " << signal << endl;
+  // NOLINTNEXTLINE(bugprone-signal-handler)
+  fprintf(stderr, "Error: Floating point exception detected. Signal %d\n", signal);
   // This should possibly throw an exception rather than abort, abort should
   // at least give access to the stack when it fails here.
   abort();
-- 
GitLab