approvals / approvals/ApprovalTests.cpp

Bug with {fmt} integration

Open
#213 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
339
Forks
55
PR merge metrics
No merged PRs in 30d

Description

Integration with {fmt} has a problem if only <fmt/core.h> is included. Because it defines FMT_VERSION that triggers {fmt} integration, but does not provides fmt::to_string which is defined in <fmt/format.h>

https://godbolt.org/z/3WTE6f3b6

<source>: In static member function 'static std::string ApprovalTests::FmtToString::toString(const T&)':
<source>:1028:25: error: 'to_string' is not a member of 'fmt'; did you mean 'std::__cxx11::to_string'?
 1028 |             return fmt::to_string(printable);
      |                         ^~~~~~~~~
In file included from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/string:54,
                 from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/locale_classes.h:40,
                 from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/ios_base.h:41,
                 from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/streambuf:43,
                 from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/streambuf_iterator.h:35,
                 from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/iterator:66,
                 from /opt/compiler-explorer/libs/fmt/10.1.1/include/fmt/core.h:14,
                 from <source>:1:
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/basic_string.h:4249:3: note: 'std::__cxx11::to_string' declared here
 4249 |   to_string(long double __val)
      |   ^~~~~~~~~
Compiler returned: 1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ApprovalTests::FmtToString::toString, where the reported call to fmt::to_string occurs, and reproduce the Compiler Explorer example using only <fmt/core.h>. Check the integration's fmt include assumptions; done means the example compiles when only that header is included and the existing formatting behavior is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.