Skip to content

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

Open
@schaerfo

Description

@schaerfo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions