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

Missing named arguments do not cause compilation error when using FMT_COMPILE #4124

Open
schaerfo opened this issue Aug 17, 2024 · 0 comments

Comments

@schaerfo
Copy link

Specifying a named argument in the format string but not providing a value does not result in a compilation error on recent GCC and Clang versions when the format string is compiled using FMT_COMPILE.

This is the case both when the argument is missing altogether (1) and when it is present but no value is assigned (2).

When the FMT_COMPILE macro is removed, both fmt::format calls result in compilation errors.

#include <fmt/format.h>
#include <fmt/compile.h>

int main() {
    using namespace fmt::literals;
    fmt::format(FMT_COMPILE("{x}")); // 1
    fmt::format(FMT_COMPILE("{x}"), "x"_a); // 2
    return 0;
}

On Compiler Explorer: https://godbolt.org/z/4zGrofeoE

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