Skip to content

Commit 125e514

Browse files
authored
build: remove -Wno-unused-result from gcc options (#5214)
Background: this flag was originally added in commit c5494ac (2015-11-24) with the message "...now builds linux+gcc...". It was later refactored in commit 62d7164 (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. Also, tests confirmed that the warning triggers if there is an unused return value. - 312793a (2026-01-01) - 682825f (2025-01-01) - 48362b2 (2024-01-01) - 3b8807d (2023-01-01) - 62d7164 (2017-01-23): refactored - c5494ac (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>
1 parent df6c3ea commit 125e514

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

src/cmake/compiler.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ endif ()
185185
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG))
186186
# gcc specific options
187187
add_compile_options ("-Wno-unused-local-typedefs")
188-
add_compile_options ("-Wno-unused-result")
189188
add_compile_options ("-Wno-aligned-new")
190189
add_compile_options ("-Wno-noexcept-type")
191190
endif ()

0 commit comments

Comments
 (0)