Skip to content

Fix GCC 16 compile Error - #3583

Merged
wasphin merged 3 commits into
apache:masterfrom
pynj2026:master
Oct 6, 2026
Merged

wasphin merged 3 commits into
apache:masterfrom
pynj2026:master

Conversation

@pynj2026

@pynj2026 pynj2026 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: No

Problem Summary:

What is changed and the side effects?

Changed:

  • The -D__STRICT_ANSI__ in CMakeLists.txt conflicts with libstdc++ 16's __int128 specialization

  • H2StreamContext is incomplete, so sizeof throws an error, causing unique_ptr to fail

Side effects:

  • Performance effects:
    No
  • Breaking backward compatibility:
    No

Check List:

1.The -D__STRICT_ANSI__ in CMakeLists.txt conflicts with libstdc++ 16's
__int128 specialization
   2. H2StreamContext is incomplete, so sizeof throws an error, causing
      unique_ptr to fail

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

GCC 16 build compatibility remains unverified and needs target-toolchain validation before approval.

Review effort: Balanced
Findings: None

What changed in this PR

Addresses GCC 16 compilation issues in bRPC’s CMake configuration and HTTP/2 request handling.

Changes:

  • Adds a compile probe before defining __STRICT_ANSI__.
  • Moves H2UnsentRequest construction and destruction out of the header to resolve incomplete-type errors.
File Description
src/​brpc/​policy/​http2_rpc_protocol.h Replaces inline constructor and destructor definitions with declarations.
src/​brpc/​policy/​http2_rpc_protocol.cpp Defines the constructor and destructor where the stream type is complete.
CMakeLists.txt Conditionally enables __STRICT_ANSI__ based on compilation support.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@wwbmmm

wwbmmm commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

LGTM

@wasphin

wasphin commented Oct 6, 2026

Copy link
Copy Markdown
Member

Could we simply remove the explicit __STRICT_ANSI__ definition instead of adding a configure-time probe?

We should let the compiler define this macro according to the selected language mode. Neither the Make nor Bazel build explicitly defines it; their -std=c++14/-std=c++17 options let the compiler set it automatically. Manually defining it in GNU mode can make standard-library headers see a mode that does not match the compiler settings.

I traced the CMake definition to commit 9b6b004 (2017), whose main change was to avoid compiling sources twice. It did not document a specific requirement for this macro, and I found no brpc source code checking it directly. Removing the manual definition would avoid the reported libstdc++ 16 conflict without introducing another configuration check. If strict ISO mode is intended, it should be selected through CMake language-mode settings rather than by forcing the macro.

1. Remove __STRICT_ANSI__ definition instead of probing it
@pynj2026 pynj2026 changed the title Fix GCC 16 compile Error: Fix GCC 16 compile Error Oct 6, 2026
@wwbmmm
wwbmmm requested a balanced review from Copilot October 6, 2026 07:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Static review found no blocking issues in these focused compatibility fixes, though GCC 16 compilation was not executed.

Review effort: Balanced
Findings: None

@wasphin wasphin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@wasphin
wasphin merged commit 84286d2 into apache:master Oct 6, 2026
25 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.

4 participants