feat(cmake): Enable (-Wall -Werror -Wextra) compilation flag to detect potential bugs early #863
feat(cmake): Enable (-Wall -Werror -Wextra) compilation flag to detect potential bugs early #863yangxk1 merged 4 commits intoapache:mainfrom
Conversation
79c69c3 to
d3c1512
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #863 +/- ##
============================================
- Coverage 80.21% 79.98% -0.24%
Complexity 615 615
============================================
Files 93 93
Lines 10255 10285 +30
Branches 1049 1051 +2
============================================
Hits 8226 8226
- Misses 1789 1819 +30
Partials 240 240
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
fix:#848 |
There was a problem hiding this comment.
Pull request overview
Enables stricter C++ compilation warnings (-Wall -Wextra -Werror) and restructures the CMake build so third-party sources are compiled separately to avoid failing the build under -Werror.
Changes:
- Enable
-Wall -Wextra -Werror(with some warning suppressions) for non-MSVC builds. - Build mini-yaml sources into a new
graphar_thirdpartystatic library and link GraphAr against it. - Address remaining warnings via copy-assignment operators and type-correct comparisons.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/build.rs | Links Rust FFI build against the new graphar_thirdparty library. |
| cpp/src/graphar/status.h | Removes redundant move in Status construction. |
| cpp/src/graphar/arrow/chunk_reader.h | Declares copy assignment operators for chunk reader classes. |
| cpp/src/graphar/arrow/chunk_reader.cc | Implements the new copy assignment operators. |
| cpp/examples/mid_level_reader_example.cc | Fixes signed/unsigned comparison warning in assertions. |
| cpp/CMakeLists.txt | Adds global warning flags and introduces graphar_thirdparty build/install + linkage. |
Comments suppressed due to low confidence (2)
cpp/src/graphar/status.h:162
- Status::FromArgs takes parameters by value (Args... args) but then uses std::forward(args)..., which defeats perfect-forwarding and can introduce unnecessary copies. Prefer Args&&... args (forwarding references) so forwarding is correct and efficient.
template <typename... Args>
static Status FromArgs(StatusCode code, Args... args) {
return Status(code, util::StringBuilder(std::forward<Args>(args)...));
}
cpp/examples/mid_level_reader_example.cc:135
- This compares an int (num_columns()) with a size_t-derived value by narrowing specific_cols.size() to int. Even in an example, it’s safer to avoid narrowing conversions; consider casting num_columns() to size_t (or using a signed size type consistently) to keep the comparison in the wider domain.
ASSERT(specific_table->num_columns() ==
static_cast<int>(specific_cols.size()) + 1);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| edge_info_ = other.edge_info_; | ||
| adj_list_type_ = other.adj_list_type_; | ||
| vertex_chunk_index_ = other.vertex_chunk_index_; | ||
| chunk_index_ = other.chunk_index_; | ||
| seek_offset_ = other.seek_offset_; | ||
| chunk_table_ = nullptr; | ||
| vertex_chunk_num_ = other.vertex_chunk_num_; | ||
| chunk_num_ = other.chunk_num_; | ||
| base_dir_ = other.base_dir_; | ||
| fs_ = other.fs_; |
There was a problem hiding this comment.
AdjListArrowChunkReader::operator=() does not copy prefix_ (but copy-ctor does). After assignment, prefix_ can be stale while base_dir_/fs_ refer to the new object, and methods like seek_src/seek_dst use prefix_ to compute paths, leading to incorrect reads. Copy prefix_ as well (and keep base_dir_ consistent with it).
…t potential bugs early
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jason <libevent@yeah.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jason <libevent@yeah.net>
Reason for this PR
-Wall -Werror -WextraThe three compilation flags (
-Wall, -Werror, -Wextra) are commonly used together in C++ projects. Combined, these flags effectively catch common bugs in C++ code and serve as a robust tool to ensure the code quality of graphar.I have addressed most of the relevant warnings in the following PRs:
Resolved unused-variables warnings: #840
Fixed compilation warnings: #849
What changes are included in this PR?
At this stage, I can only fix a subset of the remaining warnings and add the three flags (
-Wall -Werror -Wextra).third-partydependencies into a separate library to exclude them from these three flagsAre these changes tested?
yes
Are there any user-facing changes?
no