Enable strict C++ compiler warnings with -Werror#4726
Open
maxwbuckley wants to merge 3 commits intoNVIDIA:mainfrom
Open
Enable strict C++ compiler warnings with -Werror#4726maxwbuckley wants to merge 3 commits intoNVIDIA:mainfrom
maxwbuckley wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
Enable -Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wconversion -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Werror for GCC/Clang, and /W4 /WX for MSVC. Fix all ~5,500 warnings across 114 files: - Comment out unused parameters in plugin interface implementations - Add static_cast for narrowing conversions (int64_t/size_t to int32_t) - Rename constructor params to avoid shadowing member variables - Add using declarations in plugin classes to prevent hiding base class virtual methods (IPluginV2DynamicExt/IPluginV2IOExt) - Change sealed base class methods from private to protected to support using declarations in derived classes - Add virtual destructor to TimerBase - Add [[noreturn]] to reportAssertion to fix implicit-fallthrough - Add #pragma GCC system_header to third-party half.h headers - Add #undef before macro redefinitions across plugin headers - Use f suffix on float literals to prevent double promotion Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Add Clang-specific suppression for -Wvariadic-macro-arguments-omitted (triggered by CUDA toolkit headers) and -Wsign-conversion (not part of GCC's -Wconversion) - Fix deprecated literal operator syntax (remove space before _GiB etc.) - Fix Clang -Wdouble-promotion: use lroundf() instead of lround() for float args, explicit casts for long double expressions - Fix Clang -Wfloat-conversion: use explicit != 0.0F instead of implicit float-to-bool - Fix Clang -Wsign-conversion: add static_cast<size_t>() for int-to- size_t conversions in sample code Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Author
Test ResultsVerified locally
Cannot verify locally (require NVIDIA CI)
🤖 Generated with Claude Code |
Fix warnings in 10 sample files that are only compiled when the real TensorRT runtime libraries are available (not with stub libs): - BatchStream.h: add virtual destructor, int64_t narrowing casts - sampleCharRNN: shadow fix, size_t casts - sampleDynamicReshape: unused param, double-promotion, conversion - sampleINT8API: shadow fix, float/int casts - sampleIOFormats: shadow fixes, unused params, sizeof casts - sampleNamedDimensions: unused params, float literal fixes - sampleNonZeroPlugin: unused params, int64_t/size_t casts - sampleOnnxMNIST: unused param, exp() float cast - sampleOnnxMnistCoordConvAC: float literal fixes, exp() cast - sampleProgressMonitor: int-to-float cast, exp() cast, ptr diff cast Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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
-Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wconversion -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough) with-Werroron GCC/Clang and/W4 /WXon MSVC-WerrorWarning categories fixed
static_cast<>()_suffixusingdeclarations; change sealed base methods toprotectedfsuffix on float literals,lroundf()instead oflround()static_cast<float>()virtual ~ClassName() = default{}, {}initializersreportAssertionas[[noreturn]]#undefbefore redefining#pragma GCC system_headertohalf.hTest plan
-Werror— GCC 13.3: 0 errors, 0 warnings-Werror— Clang 21.1: 0 errors, 0 warnings/W4 /WX— requires Windows CI (flags are set in CMakeLists.txt)trtexec --helpruns successfully (TensorRT v10.15.01)libnvinfer.so.10.16.0)🤖 Generated with Claude Code