build: remove -Wno-unused-result from gcc options#5214
Merged
lgritz merged 1 commit intoMay 24, 2026
Merged
Conversation
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. - 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: AcademySoftwareFoundation#5196 Assisted-by: Claude / Opus 4.7 Signed-off-by: Luna Kim <177369799+luna-y-kim@users.noreply.github.com>
Collaborator
|
Kind of amazing that after all that, it can just be removed and there is nothing that pops up as a warning that it was suppressing (at least, not on any of the platforms or dependency versions being tested in our CI). There must have been a real reason it was added, but that was long ago and maybe whatever code was hitting the warnings is long gone? |
lgritz
approved these changes
May 24, 2026
Collaborator
lgritz
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
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
-Werroris enabled under the condition NOT MSVC + STOP_ON_WARNING (originally in CMakeLists.txt, now in compiler.cmake:126).Compile tests without
-Wno-unused-resultbut with-Wunused-resultexplicitly 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.Decision: the flag can be safely removed. Removing it allows gcc to catch unused return values, which is required for the
OIIO_NODISCARDandOIIO_NODISCARD_ERRORmacros to work as intended.Related: #5196
Assisted-by: Claude / Opus 4.7
Tests
N/A
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.