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

Exception with fmt::arg as floating-point precision, FMT version 100202 #3874

Closed
BorysLysyansky opened this issue Feb 29, 2024 · 1 comment
Closed

Comments

@BorysLysyansky
Copy link

BorysLysyansky commented Feb 29, 2024

I have the following minimal code compiled with GCC 13.2 (Windows), -DFMT_HEADER_ONLY:

#include <iostream>
#include <string>
#include <fmt/format.h>

int main() {
    std::cout << "Hello World! " << FMT_VERSION << std::endl;
    std::string suffix = "suffix";
    try {
        std::cout << fmt::format("{:.{p}f} {}", 1.0, suffix, fmt::arg("p", 4)) << std::endl;
    } catch (std::exception& ex) {
        std::cout << "Exception: " << ex.what() << std::endl;
    }
    return 0;
}

Link to the godbolt: https://godbolt.org/z/5qEeEv6Ma

The current FMT version generates exception:
Hello World! FMT_VERSION=100202
Exception: cannot switch from manual to automatic argument indexing

The previous FMT version has provided the following expected result:
Hello World! FMT_VERSION=100100
1.0000 suffix

Is it some expected behavior or is it some bug?

@vitaut
Copy link
Contributor

vitaut commented Feb 29, 2024

#3817

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

No branches or pull requests

2 participants