Skip to content

UPSTREAM PR #2024: Fix ambiguous FormatConvertImpl when type has both AbslStringify and AbslFormatConvert#13

Open
loci-dev wants to merge 1 commit intomainfrom
loci/pr-2024-fix-strformat-ambiguous-call
Open

UPSTREAM PR #2024: Fix ambiguous FormatConvertImpl when type has both AbslStringify and AbslFormatConvert#13
loci-dev wants to merge 1 commit intomainfrom
loci/pr-2024-fix-strformat-ambiguous-call

Conversation

@loci-dev
Copy link

Note

Source pull request: abseil/abseil-cpp#2024

When a type defines both AbslStringify and AbslFormatConvert, calling absl::StrFormat("%v", value) caused a compilation error due to ambiguous overload resolution in FormatConvertImpl.

This fix gives AbslStringify priority over AbslFormatConvert when both are defined, by:

  • Adding !HasAbslStringify<T>::value guard to the AbslFormatConvert overload of FormatConvertImpl
  • Updating ArgumentToConv() to return v conversion char set when both methods are present
    A test is added to verify that AbslStringify is called when both methods are defined.

Fixes #1966

…AbslFormatConvert

When a type defines both AbslStringify and AbslFormatConvert,
FormatConvertImpl overload resolution was ambiguous, causing a
compilation error.

Fix by giving AbslStringify priority over AbslFormatConvert when
both are defined, consistent with the intended use of AbslStringify
as the preferred extension mechanism.

Fixes #1966
@loci-dev loci-dev force-pushed the main branch 5 times, most recently from df20b95 to eacc875 Compare March 21, 2026 06:44
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.

2 participants