Enable strict C++ compiler warnings and -Werror by default#2061
Open
maxwbuckley wants to merge 1 commit intoNVIDIA:masterfrom
Open
Enable strict C++ compiler warnings and -Werror by default#2061maxwbuckley wants to merge 1 commit intoNVIDIA:masterfrom
maxwbuckley wants to merge 1 commit intoNVIDIA:masterfrom
Conversation
Add -Wextra, -Wshadow=local, -Wnon-virtual-dtor, -Woverloaded-virtual,
and -Wimplicit-fallthrough to the base CXXFLAGS in both the Makefile and
CMake build systems. Enable -Werror by default (WERROR=1) so that no new
warnings can be introduced going forward.
Fix all existing warnings across the codebase (79 files):
- Replace {0} struct initializers with {} (value-initialization)
- Complete partial aggregate initializations with missing trailing fields
- Comment out unused parameter names in callback/interface functions
- Add __attribute__((fallthrough)) for intentional switch fallthroughs
- Remove always-false unsigned comparisons (unsigned < 0)
- Add braces around empty TRACE() macro bodies
- Rename shadowing local variables in macros and nested scopes
- Mark unused static header functions as inline
- Suppress warnings from vendored NVTX3 headers via #pragma GCC system_header
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a81377d to
ad0eac4
Compare
Collaborator
|
Hi @maxwbuckley thank you for your contribution. However, this is a sweeping change on a fast moving code base so we will need to do this in a phase manner and interleave with other feature development efforts. I'm opening up an internal RFE to track the general suggestion to fix all compile time warnings and adding it to our roadmap. |
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.
Summary
-Wextra,-Wshadow=local,-Wnon-virtual-dtor,-Woverloaded-virtual,-Wimplicit-fallthroughin the base CXXFLAGS for both Makefile and CMake build systems-Werrorby default (WERROR=1) so no new warnings can be introduced going forwardWarning categories fixed
-Wmissing-field-initializers= {0}→= {}; complete partial aggregate inits-Wunused-parametertype /*name*/);(void)paramfor conditionally-used params-Wshadow=local_-Wunused-functioninlineto static header functions-Wtype-limitsunsigned < 0comparisons-Wempty-bodyTRACE()macro bodies-Wimplicit-fallthrough__attribute__((fallthrough))#pragma GCC system_headeron vendored headerDesign decisions
-Wshadow=localinstead of full-Wshadow**: Full-Wshadowproduces ~1700 warnings from constructor parameters shadowing members (idiomatic C++).-Wshadow=localcatches the genuinely dangerous local-shadows-local cases only.WERROR=0escape hatch: Developers can still build withmake WERROR=0during prototyping if needed.#pragma GCC system_headersince modifying third-party code is impractical.Test plan
astyleformatter run on all modified filesdocs/examples/build cleanly under strict flags🤖 Generated with Claude Code