From de25423a64fad024501ebc22fbef10f46332bac4 Mon Sep 17 00:00:00 2001 From: Mikhail Aksenov Date: Tue, 20 Aug 2024 17:06:52 +0300 Subject: [PATCH] Fix undefined behavior --- lib/assigner/include/zkevm_word.hpp | 4 ++-- lib/assigner/test/assigner_test.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/assigner/include/zkevm_word.hpp b/lib/assigner/include/zkevm_word.hpp index 5fd0884..2d3d1c7 100644 --- a/lib/assigner/include/zkevm_word.hpp +++ b/lib/assigner/include/zkevm_word.hpp @@ -269,9 +269,9 @@ namespace nil { template std::ostream& operator<<(std::ostream& os, const zkevm_word& obj){ - const auto bytes = obj.to_uint256be().bytes; + const auto word = obj.to_uint256be(); for (uint8_t i = 0; i < 32; i++) { - os << (int)bytes[i] << " "; + os << (int)word.bytes[i] << " "; } return os; } diff --git a/lib/assigner/test/assigner_test.cpp b/lib/assigner/test/assigner_test.cpp index f6088f8..6d9d60a 100644 --- a/lib/assigner/test/assigner_test.cpp +++ b/lib/assigner/test/assigner_test.cpp @@ -177,7 +177,7 @@ TEST_F(AssignerTest, conversions_address_to_zkevm_word) TEST_F(AssignerTest, conversions_hash_to_zkevm_word) { - ethash::hash256 hash; + ethash::hash256 hash {.bytes = {0}}; hash.bytes[2] = 10; // conversion to zkevm_word auto tmp = nil::evm_assigner::zkevm_word(hash);