Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g++-14 compilation error using named arguments inside a generic lambda #3953

Closed
andrewcorrigan opened this issue May 8, 2024 · 2 comments
Closed
Labels

Comments

@andrewcorrigan
Copy link
Contributor

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.

Is this a GCC bug or a fmtlib bug?

@vitaut
Copy link
Contributor

vitaut commented May 8, 2024

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.

@vitaut vitaut closed this as completed May 8, 2024
@vitaut vitaut added the question label May 8, 2024
@andrewcorrigan
Copy link
Contributor Author

reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants