Skip to content

Conversation

@ZedThree
Copy link
Contributor

Ignoring the -Wconversion diagnostic in make_format_args was leaking out of the header, resulting in that warning being ignored in downstream code that includes fmt/base.h:

fmt/include/fmt/base.h

Lines 2823 to 2828 in 9395ef5

constexpr FMT_ALWAYS_INLINE auto make_format_args(T&... args)
-> detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC> {
// Suppress warnings for pathological types convertible to detail::value.
FMT_PRAGMA_GCC(diagnostic ignored "-Wconversion")
return {{args...}};
}

We should push/pop the diagnostics to ensure this is cleaned up (as is done for clang and for GCC options).

See this Compiler Explorer reproducer for the problem. You can see that gcc doesn't raise a warning while clang does. Commenting out the #include <fmt/base.h> restores the correct behaviour.

Ignoring the `-Wconversion` diagnostic in `make_format_args` was
leaking out of the header, resulting in that warning being ignored in
downstream code that includes `fmt/base.h`.

Instead, we should `push`/`pop` the diagnostics to ensure this is
cleaned up.
@vitaut
Copy link
Contributor

vitaut commented Oct 25, 2025

Thanks for the PR! The lint issue is preexisting and can be ignored - I'll fix it separately.

@vitaut vitaut merged commit 9135070 into fmtlib:master Oct 25, 2025
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants