From a7c95e9cc82eb58464ca4ddaa6bab03a4b6b371c Mon Sep 17 00:00:00 2001 From: Francisco Geiman Thiesen Date: Sun, 3 Aug 2025 18:36:14 +0000 Subject: [PATCH] Fix initialization order in auto_parser constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue was that we were calling m_parser.iterate() after moving the parser, which could leave it in an invalid state. In C++20, this might behave differently than C++17. Fixed by reordering the member initializer list to call parser.iterate() BEFORE moving the parser into m_parser. This ensures the document is created while the parser is still valid. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- include/simdjson/convert.h | 3 ++- singleheader/simdjson.cpp | 2 +- singleheader/simdjson.h | 5 +++-- singleheader/singleheader.zip | Bin 8089401 -> 8089478 bytes 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/simdjson/convert.h b/include/simdjson/convert.h index 943b1244f..37c1f4bbe 100644 --- a/include/simdjson/convert.h +++ b/include/simdjson/convert.h @@ -106,7 +106,8 @@ public: explicit auto_parser(ParserType &&parser, padded_string_view const str) noexcept requires(!std::is_pointer_v) - : m_parser{std::move(parser)}, m_doc(m_parser.iterate(str)) {} + // Note: order matters! We need to call iterate BEFORE moving the parser + : m_doc(parser.iterate(str)), m_parser{std::move(parser)} {} explicit auto_parser(padded_string_view const str) noexcept requires(!std::is_pointer_v) diff --git a/singleheader/simdjson.cpp b/singleheader/simdjson.cpp index e414e8a8f..19b5701d5 100644 --- a/singleheader/simdjson.cpp +++ b/singleheader/simdjson.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-08-03 15:28:40 +0000. Do not edit! */ +/* auto-generated on 2025-08-03 18:12:50 +0000. Do not edit! */ /* including simdjson.cpp: */ /* begin file simdjson.cpp */ #define SIMDJSON_SRC_SIMDJSON_CPP diff --git a/singleheader/simdjson.h b/singleheader/simdjson.h index 43e45f31a..d7a0e6eae 100644 --- a/singleheader/simdjson.h +++ b/singleheader/simdjson.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-08-03 15:28:40 +0000. Do not edit! */ +/* auto-generated on 2025-08-03 18:12:50 +0000. Do not edit! */ /* including simdjson.h: */ /* begin file simdjson.h */ #ifndef SIMDJSON_H @@ -135358,7 +135358,8 @@ public: explicit auto_parser(ParserType &&parser, padded_string_view const str) noexcept requires(!std::is_pointer_v) - : m_parser{std::move(parser)}, m_doc(m_parser.iterate(str)) {} + // Note: order matters! We need to call iterate BEFORE moving the parser + : m_doc(parser.iterate(str)), m_parser{std::move(parser)} {} explicit auto_parser(padded_string_view const str) noexcept requires(!std::is_pointer_v) diff --git a/singleheader/singleheader.zip b/singleheader/singleheader.zip index 60d178f19e31492f0757a7740e3b4bb28f558de4..6c7981d2700c0cdf4cae8a2e9b3758c29089d607 100644 GIT binary patch delta 672 zcmZ9~OHWgA5XND!wIYgWtyil4(Rv3fRTSz41&bFHI;dbRiiIAb+V`^f)%_@6U_AN@J@~xp7p>g!h_l37ZH4Ejg zN+k9-$(%%A&sQSYj{`V}LpY2hIEogu;uxy;$I*ruPT(ZkaSEr=flkD624`^&=h1}= zxQK4_;1Uw(#bsQ2IXuE+?;PF@=olT286i z3|ppXSy|)SW;~P6n;h$mYnkpu@4#Tf6zu6-al*KhmYK>pCCjNdeg6X zX-Ov9lFhTS)>vz;z$&&%tcbPFDz(b2_0|Tf+^VoPTAQrR))p&jZM9-nrM1o4ZtbwD ztZHkgwaeOV?XmV+HCC;)&#IeOJik&=h*0@$Ii3E}SCr0m=HrRKNwRAEJeQASKMvp^ z>Tw8%(SRd3ieo7JH{m!EIDuxgpcN<4hIS-z3a8P5Gw8%woI@ARqZ=1+5tq<|%eaCR zuHqW5;|6*m+{7*1#vSyb9|IV~5QZ^=ySRr@+(#M@@DPvi7*FsN&+r^CFotnVU=kTj z;U!+-HKy?fZ!v>+c)u{0|L}Vzw=@vOgZhcl-0Vo$w9qjWevg&@TSP9J2^0U7qfFQs J`8pXgoIf@Q9I*fZ