mirror of
https://github.com/nlohmann/json.git
synced 2026-10-21 05:28:12 +00:00
Call alloc_nodes() before reading chunks.back() in the json_view chunk test
The operands of == are unsequenced, and MSVC evaluated d->edits->chunks.back() before alloc_nodes() added the new chunk, so the check compared the result with the previous chunk and failed on msvc-arm64 (Debug and Release). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+5
-2
@@ -932,8 +932,11 @@ TEST_CASE("json_view edits: the chunks of new nodes")
|
||||
// and the rest of the first chunk is still used
|
||||
CHECK(alloc_nodes(*d, 50) == first + 10);
|
||||
CHECK(d->edits->chunks.size() == 2);
|
||||
// a smaller request that does not fit starts a new (doubled) chunk
|
||||
CHECK(alloc_nodes(*d, 10) == d->edits->chunks.back().get());
|
||||
// a smaller request that does not fit starts a new (doubled) chunk; the
|
||||
// call is a statement of its own, as the operands of == are unsequenced
|
||||
// and MSVC reads chunks.back() before the call adds the chunk
|
||||
const nlohmann::detail::view::node* const doubled = alloc_nodes(*d, 10);
|
||||
CHECK(doubled == d->edits->chunks.back().get());
|
||||
CHECK(d->edits->chunks.size() == 3);
|
||||
CHECK(d->edits->chunk_end - d->edits->chunk_cur == 128 - 10);
|
||||
CHECK(d->edits->bytes == (64 + 100 + 128) * sizeof(nlohmann::detail::view::node));
|
||||
|
||||
Reference in new issue
Block a user