From 16220db75963a6f1d0a3dbdc9a0665509018b4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 28 Jun 2023 13:52:24 +0200 Subject: [PATCH] IRGeneratorForStatements: Fix undefined order of functions when generating code for index expressions --- Changelog.md | 1 + libsolidity/codegen/ir/IRGeneratorForStatements.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 2ddf6647e..fa6ea616b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ Compiler Features: Bugfixes: + * Code Generator: Fix not entirely deterministic order of functions in unoptimized Yul output. The choice of C++ compiler in some cases would result in different (but equivalent) bytecode (especially from native binaries vs emscripten binaries) * Commandline Interface: Fix internal error when using ``--stop-after parsing`` and requesting some of the outputs that require full analysis or compilation. * Commandline Interface: It is no longer possible to specify both ``--optimize-yul`` and ``--no-optimize-yul`` at the same time. * SMTChecker: Fix encoding of side-effects inside ``if`` and ``ternary conditional``statements in the BMC engine. diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 509cc28c7..e4eaaf5e8 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -2295,8 +2295,9 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess) } case DataLocation::Memory: { + string indexAccessFunction = m_utils.memoryArrayIndexAccessFunction(arrayType); string const memAddress = - m_utils.memoryArrayIndexAccessFunction(arrayType) + + indexAccessFunction + "(" + IRVariable(_indexAccess.baseExpression()).part("mpos").name() + ", " +