On Thu, Jun 2, 2016 at 8:13 AM, Jakub Jelinek <ja...@redhat.com> wrote: > When cp_fold is called on INDIRECT_REF and ARRAY*_REF and any of the > arguments change in the recursive calls, we fail to copy TREE_THIS_VOLATILE > flag. > > PR c++/71372 > * cp-gimplify.c (cp_fold): For INDIRECT_REF, if the folded expression > is INDIRECT_REF or MEM_REF, copy over TREE_READONLY, TREE_SIDE_EFFECTS > and TREE_THIS_VOLATILE flags. For ARRAY_REF and ARRAY_RANGE_REF, copy > over TREE_READONLY, TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE flags > to the newly built tree.
Hmm, maybe we should be using build_indirect_ref and build_array_ref. Or perhaps factor the simple build and set flags out of cp_build_indirect_ref and call that. If you don't feel like making that change, the patch is also OK as is. Jason