Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2690,16 +2690,16 @@ template <typename... T> struct fstring {
static_assert(count<(is_view<remove_cvref_t<T>>::value &&
std::is_reference<T>::value)...>() == 0,
"passing views as lvalues is disallowed");
if (FMT_USE_CONSTEVAL) parse_format_string<char>(s, checker(s, arg_pack()));
if (FMT_USE_CONSTEVAL)
parse_format_string<char>(str, checker(str, arg_pack()));
constexpr bool unused = detail::enforce_compile_checks<sizeof(s) != 0>();
(void)unused;
}
template <typename S,
FMT_ENABLE_IF(std::is_convertible<const S&, string_view>::value)>
FMT_CONSTEVAL FMT_ALWAYS_INLINE fstring(const S& s) : str(s) {
auto sv = string_view(str);
if (FMT_USE_CONSTEVAL)
detail::parse_format_string<char>(sv, checker(sv, arg_pack()));
detail::parse_format_string<char>(str, checker(str, arg_pack()));
constexpr bool unused = detail::enforce_compile_checks<sizeof(s) != 0>();
(void)unused;
}
Expand Down
10 changes: 10 additions & 0 deletions test/compile-error-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ if (CMAKE_CXX_STANDARD GREATER_EQUAL 20)
#endif
"
ERROR)
expect_compile(
format-string-embedded-nul-error
"
#if FMT_USE_CONSTEVAL
fmt::format(\"a\\0{}\");
#else
#error
#endif
"
ERROR)

# Compile-time argument name check
expect_compile(
Expand Down
Loading