Skip to content

Commit 32b7d17

Browse files
authored
Merge pull request ethereum#1705 from ethereum/fixasmbug
Bugfix: Deposit one stack item for non-value types in inline assembly type checking.
2 parents 419ab92 + c096166 commit 32b7d17

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Bugfixes:
1111
* Commandline interface: Do not try creating paths ``.`` and ``..``.
1212
* Type system: Fix a crash caused by continuing on fatal errors in the code.
1313
* Type system: Disallow arrays with negative length.
14+
* Inline assembly: Charge one stack slot for non-value types during analysis.
1415

1516
### 0.4.9 (2017-01-31)
1617

libsolidity/analysis/TypeChecker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
611611
fatalTypeError(SourceLocation(), "Constant variables not yet implemented for inline assembly.");
612612
if (var->isLocalVariable())
613613
pushes = var->type()->sizeOnStack();
614-
else if (var->type()->isValueType())
614+
else if (!var->type()->isValueType())
615615
pushes = 1;
616616
else
617617
pushes = 2; // slot number, intra slot offset

test/libsolidity/SolidityNameAndTypeResolution.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,19 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack)
48524852
CHECK_WARNING(text, "Inline assembly block is not balanced");
48534853
}
48544854

4855+
BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_two_stack_load)
4856+
{
4857+
char const* text = R"(
4858+
contract c {
4859+
uint8 x;
4860+
function f() {
4861+
assembly { x pop }
4862+
}
4863+
}
4864+
)";
4865+
CHECK_WARNING(text, "Inline assembly block is not balanced");
4866+
}
4867+
48554868
BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier)
48564869
{
48574870
char const* text = R"(

0 commit comments

Comments
 (0)