Hi!

MEM_REF (the only tcc_reference code with 2 operands) has TREE_READONLY set
whenever all the arguments are TREE_READONLY, which is wrong, if the
pointer/reference is read-only, it doesn't say anything about whether
what it points to is also read-only.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

I'll work on TREE_THIS_VOLATILE for MEM_REF/TARGET_MEM_REF later on, as
a follow-up.

2014-12-17  Jakub Jelinek  <ja...@redhat.com>

        PR sanitizer/64336
        * tree.c (build2_stat): Don't set TREE_READONLY on MEM_REF
        even when the arguments are TREE_READONLY.

--- gcc/tree.c.jj       2014-12-15 10:36:23.000000000 +0100
+++ gcc/tree.c  2014-12-17 10:48:07.216729576 +0100
@@ -4352,7 +4352,7 @@ build2_stat (enum tree_code code, tree t
      arguments are as well.  */
   constant = (TREE_CODE_CLASS (code) == tcc_comparison
              || TREE_CODE_CLASS (code) == tcc_binary);
-  read_only = 1;
+  read_only = code != MEM_REF;
   side_effects = TREE_SIDE_EFFECTS (t);
 
   PROCESS_ARG (0);

        Jakub

Reply via email to