From c19a6e912d4bef6bdfda5da8e04222782b13e3ed Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 18 May 2021 09:44:29 +0200 Subject: [PATCH] Readd awkward unused-result dance This was removed in 962b0f8b90884ceb68431acd8e148a6908650134, presumably with the idea that casting to void, like before, was enough. It's not, at least with gcc 11.1 --- src/fish_test_helper.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index 3ef6f99af..9e8a5750c 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -135,10 +135,14 @@ static void print_ignored_signals() { static void print_stop_cont() { signal(SIGTSTP, [](int) { - (void)write(STDOUT_FILENO, "SIGTSTP\n", strlen("SIGTSTP\n")); + // C++ compilers are awful and this is the dance we need to do to silence the "Unused result" warning. + // No, casting to (void) does *not* work. Please leave this. + auto __attribute__((unused)) _ = write(STDOUT_FILENO, "SIGTSTP\n", strlen("SIGTSTP\n")); kill(getpid(), SIGSTOP); }); - signal(SIGCONT, [](int) { (void)write(STDOUT_FILENO, "SIGCONT\n", strlen("SIGCONT\n")); }); + signal(SIGCONT, [](int) { + auto __attribute__((unused)) _ = write(STDOUT_FILENO, "SIGCONT\n", strlen("SIGCONT\n")); + }); char buff[1]; for (;;) { if (read(STDIN_FILENO, buff, sizeof buff) >= 0) {