commit 34e6b11260c579164660ac7fb1e1348000b8cf80
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Mon Sep 26 12:29:30 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Mon Sep 26 12:29:30 2016 +0200

    [cc2-qbe] Fix cast() bug
    
    We always must return the address of a result node, but in this
    case we were returning the address without filling the node.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index b3eef3c..3df8a8f 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -160,8 +160,10 @@ cast(Type *td, Node *ns, Node *nd)
        s_isint = (ts->flags & INTF) != 0;
 
        if (d_isint && s_isint) {
-               if (td->size <= ts->size)
+               if (td->size <= ts->size) {
+                       *nd = *ns;
                        return nd;
+               }
                assert(td->size == 4 || td->size == 8);
                switch (ts->size) {
                case 1:

Reply via email to