Skip to content

Upgrade to C++26 and enable strict compilation (-Wall -Werror)#89

Open
Luohaothu wants to merge 2 commits intomasterfrom
build/cpp26-and-wall-werror
Open

Upgrade to C++26 and enable strict compilation (-Wall -Werror)#89
Luohaothu wants to merge 2 commits intomasterfrom
build/cpp26-and-wall-werror

Conversation

@Luohaothu
Copy link
Contributor

@Luohaothu Luohaothu commented Feb 4, 2026

Summary

Upgrade C++ standard to C++26 and enable strict compiler warnings to improve code quality.

Changes

  • Update C++ standard requirement from C++23 to C++26
  • Enable -Wall -Werror flags in CMakeLists.txt
  • Prepares codebase for warning fix PRs

Test Plan

  • Build with GCC 15+
  • Build with Clang 21+
  • Verify all existing code compiles without warnings
  • Run full test suite

Dependencies

This PR should be merged before:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Raised the required C++ standard from C++20 to C++26 for the header-only variant.
    • Strengthened compiler warning and error checks across supported compilers, leading to stricter build-time diagnostics for downstream consumers.

- Bump C++ standard from C++23 to C++26 in CMakeLists.txt
- Enable -Wall and -Werror compiler flags for stricter builds
- Foundation for comprehensive warning fixes in follow-up PRs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @Luohaothu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to enhance the project's code quality and future-proof its development by upgrading the C++ standard to C++26 and enforcing strict compiler warnings. This foundational change will ensure that new code adheres to modern C++ practices and that any potential issues are caught early in the development cycle, setting the stage for subsequent warning-fix pull requests.

Highlights

  • C++ Standard Upgrade: The project's C++ standard requirement has been updated from C++20 to C++26 in src/CMakeLists.txt.
  • Strict Compiler Warnings: Strict compiler warnings have been enabled for the opflow target. This includes -Wall, -Wextra, and -Werror for GNU and Clang compilers, and /W4, /WX for MSVC, treating warnings as errors.
Changelog
  • src/CMakeLists.txt
    • Updated the required C++ standard for the opflow library from C++20 to C++26.
    • Added compiler options to enable -Wall, -Wextra, and -Werror for GNU and Clang compilers.
    • Added compiler options to enable /W4 and /WX for MSVC compilers.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The CMake header-only non-module comment was updated to reference C++26 (from C++20), and INTERFACE compiler warning flags were added to the opflow target: GNU/Clang (-Wall, -Wextra, -Werror) and MSVC (/W4, /WX).

Changes

Cohort / File(s) Summary
Build Configuration
src/CMakeLists.txt
Updated descriptive comment to reference C++26 (was C++20). Added public INTERFACE compiler warning flags for consumers of the opflow target: GNU/Clang: -Wall, -Wextra, -Werror; MSVC: /W4, /WX.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop, a nibble, lines refined,
The comment leaps to twenty-six in kind.
Flags raised high to catch each stray,
Warnings herd the bugs away.
I twitch my nose — the build’s polite! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: upgrading to C++26 and enabling strict compilation with -Wall and -Werror flags.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch build/cpp26-and-wall-werror

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request upgrades the project to C++26 and enables strict compiler warnings. The changes correctly update the C++ standard version. However, there is a critical issue in the implementation of the compiler warning flags in src/CMakeLists.txt. The new code uses an undefined CMake variable, which will lead to build failures in the header-only configuration. I have provided a detailed comment with a code suggestion to resolve this issue.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff28310f56

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/CMakeLists.txt`:
- Around line 125-130: The CMakeLists uses OPFLOW_TARGET_SCOPE in
target_compile_options(opflow ${OPFLOW_TARGET_SCOPE} ...) but
OPFLOW_TARGET_SCOPE is never defined; define it (e.g., set(OPFLOW_TARGET_SCOPE
INTERFACE) or PUBLIC/PRIVATE as appropriate) before its use or remove the
variable and substitute the correct scope keyword directly where
target_compile_options is called (refer to OPFLOW_TARGET_SCOPE and the
target_compile_options(opflow ...) invocation to locate the change).
- Around line 45-50: The project adds an INTERFACE target opflow and requires
C++26 via target_compile_features(opflow INTERFACE cxx_std_26), so update CI to
guarantee compilers that support C++26 (GCC >=14, Clang >=18, MSVC >=17.13) or
add an explicit pre-check in CMake to detect compiler versions and emit a clear
error; specifically adjust your CI job definitions (toolchain images/versions)
to use the stated minimums and/or implement a CMake guard around
add_library/opflow and target_compile_features that tests CMAKE_CXX_COMPILER_ID
and CMAKE_CXX_COMPILER_VERSION and fails with a helpful message if the compiler
is too old.
🧹 Nitpick comments (1)
src/CMakeLists.txt (1)

123-137: Avoid exporting -Werror//WX to consumers by default.

Using -Werror (or /WX) on an INTERFACE/PUBLIC target can break downstream builds due to their own warnings. Consider limiting Werror to build-interface or making it opt‑in.

Proposed adjustment (limit Werror to build interface)
 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
     target_compile_options(opflow ${OPFLOW_TARGET_SCOPE}
         -Wall
         -Wextra
-        -Werror
+        "$<$<BUILD_INTERFACE:-Werror>>"
     )
 endif()
 # MSVC-specific warnings
 if(MSVC)
     target_compile_options(opflow ${OPFLOW_TARGET_SCOPE}
         /W4
-        /WX
+        "$<$<BUILD_INTERFACE:/WX>>"
     )
 endif()

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.

1 participant