From b18c348cae3b57a494be95f7f36f74d921148c07 Mon Sep 17 00:00:00 2001 From: Luna Kim <177369799+luna-y-kim@users.noreply.github.com> Date: Fri, 22 May 2026 17:56:44 -0700 Subject: [PATCH] build: remove -Wno-unused-result from gcc options Background: this flag was originally added in commit c5494ac06 (2015-11-24) with the message "...now builds linux+gcc...". It was later refactored in commit 62d7164d3 (2017-01-23). From investigation, it seems to be preventative rather than reactive because it does not actively suppress warnings, but `-Werror` is enabled under the condition NOT MSVC + STOP_ON_WARNING (originally in CMakeLists.txt, now in compiler.cmake:126). Compile tests without `-Wno-unused-result` but with `-Wunused-result` explicitly enabled were conducted on the following commits, and all compiled successfully without unused result warnings. - 312793af4 (2026-01-01) - 682825f9d (2025-01-01) - 48362b26c (2024-01-01) - 3b8807df8 (2023-01-01) - 62d7164d3 (2017-01-23): refactored - c5494ac06 (2015-11-24): originally added Decision: the flag can be safely removed. Removing it allows gcc to catch unused return values, which is required for the `OIIO_NODISCARD` and `OIIO_NODISCARD_ERROR` macros to work as intended. Related: #5196 Assisted-by: Claude / Opus 4.7 Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com> --- src/cmake/compiler.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index 6936ac51b9..f975b24909 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -185,7 +185,6 @@ endif () if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)) # gcc specific options add_compile_options ("-Wno-unused-local-typedefs") - add_compile_options ("-Wno-unused-result") add_compile_options ("-Wno-aligned-new") add_compile_options ("-Wno-noexcept-type") endif ()