[hackers] [scc] [cc2-qbe] Fix cast() bug || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 26 Sep 2016 12:30:39 +0200 (CEST)

commit 34e6b11260c579164660ac7fb1e1348000b8cf80
Author: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
AuthorDate: Mon Sep 26 12:29:30 2016 +0200
Commit: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
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
_AT_@ -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:
Received on Mon Sep 26 2016 - 12:30:39 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 26 2016 - 12:36:20 CEST