Closed andrewcorrigan closed 1 month ago
Reproducer: https://godbolt.org/z/oachhYKcT
#include <iostream> #define FMT_HEADER_ONLY #include <fmt/format.h> using namespace fmt::literals; int main() { auto test = [&](auto a) { return fmt::format("{foo} {bar}", "foo"_a="foo", "bar"_a="bar"); }; std::cout << test(1) << std::endl; return 0; }
Error:
<source>:12:50: error: cannot bind non-const lvalue reference of type 'fmt::v10::detail::named_arg<char, const char (&)[4]>&' to an rvalue of type 'fmt::v10::detail::named_arg<char, const char (&)[4]>' 12 | return fmt::format("{foo} {bar}", "foo"_a="foo", "bar"_a="bar"); | ~~~~~~~^~~~~~
Changing auto a to int a works around the error.
auto a
int a
Is this a GCC bug or a fmtlib bug?
Looks like a compiler bug to me and it compiles on an earlier gcc version: https://godbolt.org/z/K1on3vYnf. Please report to gcc devs.
reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114994
Reproducer: https://godbolt.org/z/oachhYKcT
Error:
Changing
auto a
toint a
works around the error.Is this a GCC bug or a fmtlib bug?