diff --git a/include/fmt/format.h b/include/fmt/format.h index 5779eab471d5..5f7c96c4ab9b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3525,11 +3525,13 @@ struct formatter FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + auto begin = ctx.begin(), end = ctx.end(); + if (begin == end) return begin; using handler_type = detail::dynamic_specs_handler; auto type = detail::type_constant::value; detail::specs_checker handler(handler_type(specs_, ctx), type); - auto it = parse_format_specs(ctx.begin(), ctx.end(), handler); + auto it = parse_format_specs(begin, end, handler); auto eh = ctx.error_handler(); switch (type) { case detail::type::none_type: