You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<array>
#include<fmt/compile.h>
#include<fmt/ranges.h>intmain() {
std::array<int, 3> values{1, 2, 3};
auto s = fmt::format(FMT_COMPILE("array={}"), values);
fmt::print("{}\n", s);
}
Expected output: array=[1, 2, 3]
It works without FMT_COMPILE.
This issue seems to have been introduced in 61e3b92.
A branch in nested_format_specs::write attempts to construct an iterator-specific FormatContext from a basic_appender<char>, which cannot be converted to a std::back_insert_iterator<std::string> as required by the generic_context<std::back_insert_iterator<std::string>, char> constructor. This example never actually tries to construct the FormatContext (as the branch is for padding, and we don't specify a width), but it still needs to be instantiated.
FMT_COMPILE failing on std::array looks like a missing formatter / compile-time path for contiguous fixed-size ranges. I will reproduce against current main, check how std::span / other ranges are handled in the compile-time formatter, and add a failing test then the fix so both runtime and FMT_COMPILE format std::array the same way.
Will open a PR with a focused test case once I have the repro locked down.
I opened #4974 with a fix and the reproducer from this issue as a test in compile-test.cc. It keeps the outer context's arguments, so dynamic element specs like {:*>20:{}} also work.
Activity
HarshXAI commentedon Sep 29, 2026
I can take this.
FMT_COMPILEfailing onstd::arraylooks like a missing formatter / compile-time path for contiguous fixed-size ranges. I will reproduce against currentmain, check howstd::span/ other ranges are handled in the compile-time formatter, and add a failing test then the fix so both runtime andFMT_COMPILEformatstd::arraythe same way.Will open a PR with a focused test case once I have the repro locked down.
mayankjaiswal12 commentedon Oct 5, 2026
I opened #4974 with a fix and the reproducer from this issue as a test in compile-test.cc. It keeps the outer context's arguments, so dynamic element specs like {:*>20:{}} also work.