diff options
author | mikhnenko <[email protected]> | 2025-07-11 21:15:34 +0300 |
---|---|---|
committer | mikhnenko <[email protected]> | 2025-07-11 21:31:04 +0300 |
commit | b1acfe927c4ba28fce6a5cd0f36cd211f0cae5ec (patch) | |
tree | d6bc5ad4aec832090ce8def1c733ef0676e23a1e | |
parent | 05a6108a6e15fce066485fd931a86f0225dc3c43 (diff) |
Use real begin and end for avoiding pointer subtraction
commit_hash:2004c57c2d7a9b04faeb56af6e904abb4a554793
-rw-r--r-- | contrib/libs/fmt/include/fmt/core.h | 8 | ||||
-rw-r--r-- | contrib/libs/fmt/patches/02-clang20-consteval-fix.patch | 25 |
2 files changed, 31 insertions, 2 deletions
diff --git a/contrib/libs/fmt/include/fmt/core.h b/contrib/libs/fmt/include/fmt/core.h index fd89ed5fc4c..65c415bed73 100644 --- a/contrib/libs/fmt/include/fmt/core.h +++ b/contrib/libs/fmt/include/fmt/core.h @@ -664,6 +664,10 @@ class basic_format_parse_context : private ErrorHandler { format_str_.remove_prefix(detail::to_unsigned(it - begin())); } + constexpr void reset_str(basic_string_view<Char> format_str) { + format_str_ = format_str; + } + /** Reports an error if using the manual argument indexing; otherwise returns the next argument index and switches to the automatic indexing. @@ -2925,9 +2929,9 @@ class format_string_checker { FMT_CONSTEXPR void on_replacement_field(int, const Char*) {} - FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*) + FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char* end) -> const Char* { - context_.advance_to(context_.begin() + (begin - &*context_.begin())); + context_.reset_str(basic_string_view<Char>(begin, end - begin)); // id >= 0 check is a workaround for gcc 10 bug (#2065). return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin; } diff --git a/contrib/libs/fmt/patches/02-clang20-consteval-fix.patch b/contrib/libs/fmt/patches/02-clang20-consteval-fix.patch new file mode 100644 index 00000000000..763eacccab6 --- /dev/null +++ b/contrib/libs/fmt/patches/02-clang20-consteval-fix.patch @@ -0,0 +1,25 @@ +--- contrib/libs/fmt/include/fmt/core.h (90c4a7fc42b3aea434be962384827016df164b8a) ++++ contrib/libs/fmt/include/fmt/core.h (working tree) +@@ -664,6 +664,10 @@ class basic_format_parse_context : private ErrorHandler { + format_str_.remove_prefix(detail::to_unsigned(it - begin())); + } + ++ constexpr void reset_str(basic_string_view<Char> format_str) { ++ format_str_ = format_str; ++ } ++ + /** + Reports an error if using the manual argument indexing; otherwise returns + the next argument index and switches to the automatic indexing. +@@ -2925,9 +2929,9 @@ class format_string_checker { + + FMT_CONSTEXPR void on_replacement_field(int, const Char*) {} + +- FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char*) ++ FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char* end) + -> const Char* { +- context_.advance_to(context_.begin() + (begin - &*context_.begin())); ++ context_.reset_str(basic_string_view<Char>(begin, end - begin)); + // id >= 0 check is a workaround for gcc 10 bug (#2065). + return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin; + } |