Add CppCoreGuidelines setup#21
Merged
Merged
Conversation
This reverts commit 2b6be59.
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
Hardens the warning configuration for the traincascade and
test_traincascadetargets by introducing a curated set of compiler diagnostics inspired by the C++ Core Guidelines and thecppbestpracticesbaseline. Flags are split per compiler (GNU,Clang,MSVC) so each toolchain enables the strictest set it actually supports.Motivation
The previous configuration only enabled
-Wall -Wextra -Wpedantic -Werror(or/W4 /WX). That misses a large class of bugs (shadowing, sign/integer conversions, switch coverage, format issues, uninitialized reads, aliasing violations, etc.) that the Core Guidelines explicitly call out. This PR raises the baseline without rewriting any production code.Changes
-Wold-style-cast,-Wsign-conversion,-Wconversion, MSVC/w14365) are commented out with a# Fix in codenote so they can be re-enabled incrementally.test_traincascadetarget: enables the full set including the warnings above, since the test code is clean.ubuntu.yml,macos.yml,windows.yml,static_check.yml,codeql-analysis.yml): action version bumps, clang-tidy setup fix, disabled Java build, OpenCV version bump.Per-compiler flag coverage
Common (GCC + Clang):
-Wcast-qual -Wshadow -Wnull-dereference -Wmisleading-indentation -Wimplicit-fallthrough -Wswitch-enum -Wshift-negative-value -Wformat=2 -Wformat-security -fstrict-aliasing -Wstack-protector -fstack-protector-strong -Wnon-virtual-dtor -Woverloaded-virtual -Wuninitialized -Walloca -WvlaGCC-only:
-Wcast-align=strict -Warith-conversion -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Wshift-overflow=2 -Wstrict-aliasing=3 -Wmaybe-uninitializedClang-only:
-Wcast-align -Wlogical-op-parentheses -Wshift-overflow -Wconditional-uninitialized -Wsometimes-uninitializedMSVC:
/Zc:__cplusplus /Zc:preprocessor /Zc:inlineplus the/w14xxxset covering shadowing, conversions, switch/enum, fallthrough, format, virtual/override hygiene, and uninitialized reads.Validation
static_check.yml.Follow-ups
Re-enable the warnings currently commented out as
# Fix in codeonce the corresponding issues in traincascade are cleaned up:-Wold-style-cast-Wconversion/-Wsign-conversion(MSVC/w14365)