fmt icon indicating copy to clipboard operation
fmt copied to clipboard

`format_as` fails when called with certain `std::views`

Open fennewald opened this issue 1 year ago • 4 comments

Reproduction

Godbolt link

Summary

A format_as definition that returns a std::views::filter_view, like so:

auto format_as(CodecMask m) {
    return CodecMask::k_codecs | std::views::filter([&](auto c) { return m.has(c); });
}

does not compile:

CodecMask m;
m.add(Codec::H264);

fmt::println("{}", format_as(m)); // valid
fmt::pritnln("{}", m); // invalid

Stack Overflow

I posted this to stack overflow originally, expecting some mistake of my own. People there suggested that this may be a bug with fmt itself, hence this issue. The explanation given there may prove to be of value.

Notes

I expected the most recent commit (274ba26) may have helped, as it appears to be related to this type of issue. It is worth noting the error message changes when tested against 10.1.1 and trunk in godbolt, but both still do fail.

fennewald avatar Dec 11 '23 15:12 fennewald

There is a simpler repro for the set_debug_format error in https://github.com/fmtlib/fmt/issues/3763#issue-2048061455.

vitaut avatar Dec 19 '23 23:12 vitaut

Understood, closing as duplicated!

fennewald avatar Dec 20 '23 13:12 fennewald

Let's keep this one open for tracking the issue.

vitaut avatar Dec 20 '23 14:12 vitaut

The set_debug_format issue is fixed in https://github.com/fmtlib/fmt/commit/3eb3aef5753b91d689b496a629b9dc5c4a7cd348 but looks like there is another problem.

vitaut avatar Dec 23 '23 16:12 vitaut

@vitaut This issue should be fixed by #3955

Arghnews avatar May 13 '24 18:05 Arghnews

The original repro compiles now: https://godbolt.org/z/ahh86ME13. Thanks @Arghnews for the fix!

vitaut avatar May 14 '24 13:05 vitaut