------- Comment #1 from burnus at gcc dot gnu dot org  2010-07-01 06:21 -------
Confirm.

Valgrind shows:

==11328== Invalid read of size 8
==11328==    at 0x6CBB86: fold_convert_loc (fold-const.c:1856)
==11328==    by 0x58E7A3: allocate_temp_for_forall_nest_1 (trans-stmt.c:2583)
==11328==    by 0x58F394: gfc_trans_assign_need_temp (trans-stmt.c:2702)
==11328==    by 0x59284C: gfc_trans_forall_1 (trans-stmt.c:3158)
==11328==    by 0x551DFF: trans_code (trans.c:1205)

Failing is the following line in fold-const.c
  tree orig = TREE_TYPE (arg);
which is the second argument in the following line of
allocate_temp_for_forall_nest_1:
   unit = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (type));

It is set in gfc_trans_assign_need_temp:

  if (expr1->ts.type == BT_CHARACTER && expr1->ts.u.cl->length)
    ...
  else
    type = gfc_typenode_for_spec (&expr1->ts);

For the example, expr1->ts.type == BT_CHARACTER but expr1->ts.u.cl->length ==
NULL.

The symbol itself has:
(gdb) p *expr1->symtree->n.sym->ts.u.cl->length->value.integer._mp_d
$8 = 10

And the size is given by the expression:
(gdb) p expr1->ref->u.ss.start->expr_type 
$19 = EXPR_VARIABLE


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.3.4 4.4.0 4.5.1 4.6.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-01 06:21:38
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44735

Reply via email to