Skip to content

fix(Foundation): resolve Poco::format ambiguity with std::format in C++23#5170

Merged
matejk merged 1 commit intomainfrom
4966-poco-format-fix
Jan 21, 2026
Merged

fix(Foundation): resolve Poco::format ambiguity with std::format in C++23#5170
matejk merged 1 commit intomainfrom
4966-poco-format-fix

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented Jan 20, 2026

Summary

Fixes #4966 - Resolves compilation error when using Poco::format with C++23 and std::format.

Problem

When compiling with C++23 and including both Poco/Format.h and the standard <format> header (either directly or transitively), the compiler encounters ambiguity between Poco::format and std::format functions.

This issue is particularly evident when:

  • Using C++23 standard
  • Using libstdc++ 14 or later
  • Including Poco headers in consumer projects (not when building Poco itself)
  • Using C++20 modules with Poco headers in the global module fragment

The ambiguity occurs in the formatAny() helper functions which call format() without explicit namespace qualification, allowing ADL (Argument-Dependent Lookup) to consider both Poco::format and std::format as candidates.

Solution

Use explicit global namespace qualification (::Poco::format) in the formatAny() helper functions to ensure only Poco::format is considered, eliminating the ambiguity with std::format.

Changes

  • Modified Foundation/include/Poco/Format.h:
    • Changed Poco::format() to ::Poco::format() in both formatAny() inline functions

Testing

  • Verified Foundation library builds successfully
  • Tested compilation with C++23 including both <format> and Poco/Format.h
  • The fix ensures backward compatibility while resolving the C++23 ambiguity

@matejk matejk force-pushed the 4966-poco-format-fix branch from b971028 to ffbb089 Compare January 20, 2026 19:52
@matejk matejk force-pushed the 4966-poco-format-fix branch from ffbb089 to a6f9161 Compare January 20, 2026 19:54
@matejk matejk merged commit c278955 into main Jan 21, 2026
100 checks passed
@matejk matejk deleted the 4966-poco-format-fix branch January 21, 2026 07:34
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.

Poco::format compile error c++23

1 participant