From 7083144bda85d833383dfc7cfd94c0c362fa69a1 Mon Sep 17 00:00:00 2001 From: Harrand Date: Wed, 15 May 2024 22:48:40 +0100 Subject: [PATCH] [cpp] attempt to fix clang/gcc compile errors that dont reproduce on windows --- cpp/src/lex.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/lex.cpp b/cpp/src/lex.cpp index 2f92088..7198f02 100644 --- a/cpp/src/lex.cpp +++ b/cpp/src/lex.cpp @@ -86,7 +86,8 @@ namespace lex std::size_t snippet_begin = this->cursor > snippet_width ? (this->cursor - snippet_width) : 0; std::size_t snippet_end = (this->cursor + snippet_width) >= this->source.size() ? this->source.size() : (this->cursor + snippet_width); std::string_view snippet = this->source.substr(snippet_begin, snippet_end - snippet_begin); - diag::error(errcode, "at {}, {}", curloc.to_string(), std::vformat(msg, std::make_format_args(dodgy_part.substr(0, std::min(dodgy_part.size(), static_cast(2u))), snippet))); + std::string_view dodgy_snippet = dodgy_part.substr(0, std::min(dodgy_part.size(), static_cast(2u))); + diag::error(errcode, "at {}, {}", curloc.to_string(), std::vformat(msg, std::make_format_args(dodgy_snippet, snippet))); } void unrecognised_tokens(std::string_view dodgy_part)