Skip to content

build: remove -Wno-unused-result from gcc options#5214

Merged
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
luna-y-kim:remove-gcc-wno-unused-result
May 24, 2026
Merged

build: remove -Wno-unused-result from gcc options#5214
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
luna-y-kim:remove-gcc-wno-unused-result

Conversation

@luna-y-kim
Copy link
Copy Markdown
Contributor

@luna-y-kim luna-y-kim commented May 24, 2026

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 -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.

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


Tests

N/A

Checklist:

  • I have read the guidelines on contributions and code review procedures.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • (N/A) I have updated the documentation if my PR adds features or changes
    behavior.
  • (N/A) I am sure that this PR's changes are tested in the testsuite.
  • I have run and passed the testsuite in CI before submitting the
    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.)
  • My code follows the prevailing code style of this project and I
    fixed any problems reported by the clang-format CI test.
  • (N/A) If I added or modified a public C++ API call, I have also amended the
    corresponding Python bindings. If altering ImageBufAlgo functions, I also
    exposed the new functionality as oiiotool options.

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>
@luna-y-kim luna-y-kim marked this pull request as ready for review May 24, 2026 02:18
@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 24, 2026

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?

Copy link
Copy Markdown
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@lgritz lgritz merged commit 125e514 into AcademySoftwareFoundation:main May 24, 2026
61 checks passed
@luna-y-kim luna-y-kim deleted the remove-gcc-wno-unused-result branch May 24, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants