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

The vformat & vprint functions produce incorrect output when mixing named and positional arguments. #3817

Closed
calebkiage opened this issue Jan 18, 2024 · 2 comments

Comments

@calebkiage
Copy link

When using the dynamic_format_arg_store with both named and positional args on fmt, the output produced is incorrect.

A minimal reproduction of the issue is shown in the snippet below:

A minimal reproduction of the issue is shown in the snippet below:
#include <fmt/args.h>
#include <fmt/core.h>

int main() {
    fmt::dynamic_format_arg_store<fmt::format_context> store;
    store.push_back(1);
    store.push_back(fmt::arg("b", 2));
    store.push_back(3);

    // Prints 1 2 2 instead of 1 2 3
    fmt::vprint("{} {b} {}", store);
}

godbolt link

@calebkiage
Copy link
Author

I've noticed the issue doesn't happen if the named arguments come after all the positional arguments.
godbolt link

@vitaut
Copy link
Contributor

vitaut commented Jan 20, 2024

It was supposed to be an error similarly to mixing manual/automatic indexing but the check was missing. Fixed in 4c5b4af. Thanks for reporting.

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