Patchwork [PR48689] ICE in fold-const.c:13798 with fold checking

login
register
mail settings
Submitter Tom de Vries
Date May 22, 2011, 4:26 p.m.
Message ID <4DD9391E.3060907@codesourcery.com>
Download mbox | patch
Permalink /patch/96758/
State New
Headers show

Comments

Tom de Vries - May 22, 2011, 4:26 p.m.
Hi,

I also ran into this assert:
...
<built-in>:0:0: internal compiler error: tree check: expected tree that
contains 'common' structure, have 'integer_cst' in fold_checksum_tree, at
fold-const.c:13798
...

With a recent change in r172386, using a TREE_CHAIN on an INTEGER_CST has become
illegal:
...
	* tree.h (struct tree_int_cst, struct real_value): Include tree_typed
	instead of tree_common.
	* tree.c (initialize_tree_contains_struct): Mark such nodes as being
	TS_TYPED rather than TS_COMMON.
...

I fixed it by guarding the use of TREE_CHAIN with CODE_CONTAINS_STRUCT
(TS_COMMON), to make sure that the tree has a TREE_CHAIN field.

Tested with --enable-checking=all build.

Ok for trunk?

Thanks,
- Tom


2011-05-22  Tom de Vries  <tom@codesourcery.com>

	PR middle-end/48689
	* fold-const.c (fold_checksum_tree): Guard TREE_CHAIN use with
	CODE_CONTAINS_STRUCT (TS_COMMON).
Richard Guenther - May 22, 2011, 5:57 p.m.
On Sun, May 22, 2011 at 6:26 PM, Tom de Vries <vries@codesourcery.com> wrote:
> Hi,
>
> I also ran into this assert:
> ...
> <built-in>:0:0: internal compiler error: tree check: expected tree that
> contains 'common' structure, have 'integer_cst' in fold_checksum_tree, at
> fold-const.c:13798
> ...
>
> With a recent change in r172386, using a TREE_CHAIN on an INTEGER_CST has become
> illegal:
> ...
>        * tree.h (struct tree_int_cst, struct real_value): Include tree_typed
>        instead of tree_common.
>        * tree.c (initialize_tree_contains_struct): Mark such nodes as being
>        TS_TYPED rather than TS_COMMON.
> ...
>
> I fixed it by guarding the use of TREE_CHAIN with CODE_CONTAINS_STRUCT
> (TS_COMMON), to make sure that the tree has a TREE_CHAIN field.
>
> Tested with --enable-checking=all build.
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> - Tom
>
>
> 2011-05-22  Tom de Vries  <tom@codesourcery.com>
>
>        PR middle-end/48689
>        * fold-const.c (fold_checksum_tree): Guard TREE_CHAIN use with
>        CODE_CONTAINS_STRUCT (TS_COMMON).
>

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 173734)
+++ gcc/fold-const.c (working copy)
@@ -13822,7 +13823,8 @@  recursive_label:
   if (TREE_CODE_CLASS (code) != tcc_type
       && TREE_CODE_CLASS (code) != tcc_declaration
       && code != TREE_LIST
-      && code != SSA_NAME)
+      && code != SSA_NAME
+      && CODE_CONTAINS_STRUCT (code, TS_COMMON))
     fold_checksum_tree (TREE_CHAIN (expr), ctx, ht);
   switch (TREE_CODE_CLASS (code))
     {