Message ID | 4F01040A.8050803@oracle.com |
---|---|
State | New |
Headers | show |
On 01/01/2012 08:10 PM, Paolo Carlini wrote: > The analysis is confirmed by the fact that the rather heavy handed > patchlet which I'm attaching, which uses copy_node to avoid the > corruption, "works". How do we normally handle this kind of situation? In most cases, trees are unshared at instantiation time, but that doesn't apply to constants like this. The patch is OK. Jason
On 01/02/2012 02:49 AM, Jason Merrill wrote: > On 01/01/2012 08:10 PM, Paolo Carlini wrote: >> The analysis is confirmed by the fact that the rather heavy handed >> patchlet which I'm attaching, which uses copy_node to avoid the >> corruption, "works". How do we normally handle this kind of situation? > In most cases, trees are unshared at instantiation time, but that > doesn't apply to constants like this. The patch is OK. Oh I see, thanks. Then I'm going to properly test it, etc, and if everything goes well, I'll post what I will actually commit. Thanks again, Paolo.
On Mon, Jan 2, 2012 at 3:24 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > On 01/02/2012 02:49 AM, Jason Merrill wrote: >> >> On 01/01/2012 08:10 PM, Paolo Carlini wrote: >>> >>> The analysis is confirmed by the fact that the rather heavy handed >>> patchlet which I'm attaching, which uses copy_node to avoid the >>> corruption, "works". How do we normally handle this kind of situation? >> >> In most cases, trees are unshared at instantiation time, but that doesn't >> apply to constants like this. The patch is OK. > > Oh I see, thanks. Then I'm going to properly test it, etc, and if everything > goes well, I'll post what I will actually commit. I think it's enough to call copy_node for CONSTANT_CLASS_P objects. > Thanks again, > Paolo.
Index: typeck2.c =================================================================== --- typeck2.c (revision 182776) +++ typeck2.c (working copy) @@ -902,7 +902,11 @@ digest_init_r (tree type, tree init, bool nested, } } - TREE_TYPE (init) = type; + if (type != TREE_TYPE (init)) + { + init = copy_node (init); + TREE_TYPE (init) = type; + } if (TYPE_DOMAIN (type) != 0 && TREE_CONSTANT (TYPE_SIZE (type))) { int size = TREE_INT_CST_LOW (TYPE_SIZE (type));