diff options
author | chriseth <c@ethdev.com> | 2015-07-14 22:37:11 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-07-14 22:40:16 +0800 |
commit | a3dace66e17968450322da6d84b5081c9cf56f98 (patch) | |
tree | 9fd622ec0d9f5e67177343cceb50d3ba5ec83942 /ExpressionCompiler.cpp | |
parent | da818b1acdd8f02fccd18779cfb0ac397d7e61b1 (diff) | |
download | dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar.gz dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar.bz2 dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar.lz dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar.xz dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.tar.zst dexon-solidity-a3dace66e17968450322da6d84b5081c9cf56f98.zip |
Fix comparison between bytes types.
Fixes #2087
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 05835818..2ce68111 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -942,24 +942,27 @@ void ExpressionCompiler::appendCompareOperatorCode(Token::Value _operator, Type } else { - IntegerType const& type = dynamic_cast<IntegerType const&>(_type); - bool const c_isSigned = type.isSigned(); + bool isSigned = false; + if (auto type = dynamic_cast<IntegerType const*>(&_type)) + isSigned = type->isSigned(); switch (_operator) { case Token::GreaterThanOrEqual: - m_context << (c_isSigned ? eth::Instruction::SLT : eth::Instruction::LT) - << eth::Instruction::ISZERO; + m_context << + (isSigned ? eth::Instruction::SLT : eth::Instruction::LT) << + eth::Instruction::ISZERO; break; case Token::LessThanOrEqual: - m_context << (c_isSigned ? eth::Instruction::SGT : eth::Instruction::GT) - << eth::Instruction::ISZERO; + m_context << + (isSigned ? eth::Instruction::SGT : eth::Instruction::GT) << + eth::Instruction::ISZERO; break; case Token::GreaterThan: - m_context << (c_isSigned ? eth::Instruction::SGT : eth::Instruction::GT); + m_context << (isSigned ? eth::Instruction::SGT : eth::Instruction::GT); break; case Token::LessThan: - m_context << (c_isSigned ? eth::Instruction::SLT : eth::Instruction::LT); + m_context << (isSigned ? eth::Instruction::SLT : eth::Instruction::LT); break; default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown comparison operator.")); |