Fixed segfault in AstNode::asReal
authorClifford Wolf <clifford@clifford.at>
Fri, 25 Sep 2015 10:38:01 +0000 (12:38 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 25 Sep 2015 10:38:01 +0000 (12:38 +0200)
frontends/ast/ast.cc

index 5044eeabcbb1b70aa6e05d78a37e959d99e86904..3e163bae799ca649dfb3980fe2d09f2e9d81a741 100644 (file)
@@ -831,7 +831,7 @@ double AstNode::asReal(bool is_signed)
        {
                RTLIL::Const val(bits);
 
-               bool is_negative = is_signed && val.bits.back() == RTLIL::State::S1;
+               bool is_negative = is_signed && !val.bits.empty() && val.bits.back() == RTLIL::State::S1;
                if (is_negative)
                        val = const_neg(val, val, false, false, val.bits.size());