Skip to content

fix build: make parse constexpr for new fmt#1287

Open
Malevrovich wants to merge 1 commit into
userver-framework:developfrom
Malevrovich:fix-macos-alpine-build
Open

fix build: make parse constexpr for new fmt#1287
Malevrovich wants to merge 1 commit into
userver-framework:developfrom
Malevrovich:fix-macos-alpine-build

Conversation

@Malevrovich

Copy link
Copy Markdown
Contributor

fmt v11+ uses consteval format string validation (fstring) which requires fmt::formatter::parse() to be a constant expression. The non-constexpr parse() methods in protobuf test utils caused compile errors like:

error: call to consteval function 'fmt::fstring<...>' is not a constant expression
note: non-constexpr function 'parse' cannot be used in a constant expression

Make all 4 parse() methods constexpr and simplify them to return ctx.begin(), matching the existing pattern in http_method.hpp and sockaddr.hpp. The removed runtime throw guard is no longer needed — fmt's compile-time checker now catches invalid format specs at compile time with "unknown format specifier" error.

fmt v11+ uses consteval format string validation (fstring) which
requires fmt::formatter::parse() to be a constant expression.
The non-constexpr parse() methods in protobuf test utils caused
compile errors like:

  error: call to consteval function 'fmt::fstring<...>' is not a constant expression
  note: non-constexpr function 'parse' cannot be used in a constant expression

Make all 4 parse() methods constexpr and simplify them to
return ctx.begin(), matching the existing pattern in http_method.hpp
and sockaddr.hpp. The removed runtime throw guard is no longer
needed — fmt's compile-time checker now catches invalid format
specs at compile time with "unknown format specifier" error.
@Malevrovich

Copy link
Copy Markdown
Contributor Author

LGTM

@robot-magpie

robot-magpie Bot commented Jul 3, 2026

Copy link
Copy Markdown

Many thanks for the PR! @Malevrovich is now importing your pull request into our internal upstream repository.

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