This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] machine dependent constant in tree-ssa-structalias.c


The following code produced an undefined result on the apeNEXT
architecture (BITS_PER_UNIT=64).

typedef struct {
  int a, b, c;
} S;

int result[3];

int main() {
   S x;

   x.a = 0x78;
   x.b = 0x79;
   x.c = 0x80;

   result[0] = x.a;
   result[1] = x.b;
   result[2] = x.c;

   return result[2];
}


The patch is obvious, could somebody commit it?

Alessandro Lonardo

===================================================================
--- tree-ssa-structalias.c      (revision 117826)
+++ tree-ssa-structalias.c      (working copy)
@@ -2309,7 +2309,7 @@
       || TREE_CODE (DECL_FIELD_BIT_OFFSET (fdecl)) != INTEGER_CST)
     return -1;

-  return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * 8)
+  return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * BITS_PER_UNIT)
          + tree_low_cst (DECL_FIELD_BIT_OFFSET (fdecl), 1);
 }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]