Skip to content

Comments

feat(cmake): Enable (-Wall -Werror -Wextra) compilation flag to detect potential bugs early #863

Merged
yangxk1 merged 4 commits intoapache:mainfrom
SYaoJun:214_wextra
Feb 25, 2026
Merged

feat(cmake): Enable (-Wall -Werror -Wextra) compilation flag to detect potential bugs early #863
yangxk1 merged 4 commits intoapache:mainfrom
SYaoJun:214_wextra

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Feb 14, 2026

Reason for this PR

  1. Add compilation flags -Wall -Werror -Wextra

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

  1. Compile third-party dependencies into a separate library to exclude them from these three flags
  2. Fix the remaining warnings
  • missing copy assignment operators
  • unused parameters

Are these changes tested?

yes

Are there any user-facing changes?

no

@SYaoJun SYaoJun changed the title feat(cmake): Enable compilation flag to detect potential bugs early feat(cmake): Enable (-Wall -Werror -Wextra) compilation flag to detect potential bugs early Feb 14, 2026
@SYaoJun SYaoJun force-pushed the 214_wextra branch 4 times, most recently from 79c69c3 to d3c1512 Compare February 14, 2026 14:54
@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 3.22581% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.98%. Comparing base (89c167a) to head (7e0ef9d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
cpp/src/graphar/arrow/chunk_reader.cc 0.00% 30 Missing ⚠️
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              
Flag Coverage Δ
cpp 71.10% <3.22%> (-0.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SYaoJun
Copy link
Contributor Author

SYaoJun commented Feb 18, 2026

fix:#848

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comment on lines +555 to +564
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_;
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
SYaoJun and others added 4 commits February 25, 2026 12:02
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>
@yangxk1 yangxk1 merged commit 31b78b0 into apache:main Feb 25, 2026
12 checks passed
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.

3 participants