From ce678fd986a3aa3526bc9a91574c8db5e4cd104f Mon Sep 17 00:00:00 2001 From: John Keiser Date: Fri, 5 Feb 2021 18:51:52 -0800 Subject: [PATCH] Fix GCC 7 strict-overflow warning --- include/simdjson/generic/ondemand/object_iterator-inl.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/simdjson/generic/ondemand/object_iterator-inl.h b/include/simdjson/generic/ondemand/object_iterator-inl.h index 5b8282bb4..45f251c8f 100644 --- a/include/simdjson/generic/ondemand/object_iterator-inl.h +++ b/include/simdjson/generic/ondemand/object_iterator-inl.h @@ -25,6 +25,12 @@ simdjson_really_inline bool object_iterator::operator==(const object_iterator &o simdjson_really_inline bool object_iterator::operator!=(const object_iterator &) const noexcept { return iter.is_open(); } + +// GCC 7 warns when the first line of this function is inlined away into oblivion due to the caller +// relating depth and iterator depth, which is a desired effect. It does not happen if is_open is +// marked non-inline. +SIMDJSON_PUSH_DISABLE_WARNINGS +SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING simdjson_really_inline object_iterator &object_iterator::operator++() noexcept { // TODO this is a safety rail ... users should exit loops as soon as they receive an error. // Nonetheless, let's see if performance is OK with this if statement--the compiler may give it to us for free. @@ -37,6 +43,7 @@ simdjson_really_inline object_iterator &object_iterator::operator++() noexcept { if ((error = iter.has_next_field().get(has_value) )) { return *this; }; return *this; } +SIMDJSON_POP_DISABLE_WARNINGS // // ### Live States