------- Comment #9 from paul dot richard dot thomas at cea dot fr 2006-01-31 12:58 ------- If you look at the code produced by this final example, the 2nd argument of _gfc_allocate is null. This comes about because the TYPE_SIZE_UNIT that Jakub hated me setting directly is a NULL_TREE. I suspect that his patch will fix this. Otherwise, this works and will be submitted tonight:
Index: gcc/fortran/trans-stmt.c =================================================================== --- gcc/fortran/trans-stmt.c (révision 110394) +++ gcc/fortran/trans-stmt.c (copie de travail) @@ -3254,8 +3254,12 @@ val = gfc_create_var (ppvoid_type_node, "ptr"); tmp = gfc_build_addr_expr (ppvoid_type_node, se.expr); gfc_add_modify_expr (&se.pre, val, tmp); - - tmp = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (se.expr))); + + tmp = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (se.expr))); + + if (expr->ts.type == BT_CHARACTER && tmp == NULL_TREE) + tmp = se.string_length; + parm = gfc_chainon_list (NULL_TREE, val); parm = gfc_chainon_list (parm, tmp); parm = gfc_chainon_list (parm, pstat); This results in the hidden charlen dummy argument being passed to the library allocate. Hah! I just undid the above and applied Jakub's patch; as I suspected it fixes the bug and produces the following code: foo (self, _self) { bit_size_type D.802; <unnamed type> D.803; D.802 = (bit_size_type) (<unnamed type>) _self * 8; D.803 = (<unnamed type>) _self; *self = 0B; { void * * ptr.0; ptr.0 = (void * *) self; _gfortran_allocate (ptr.0, (<unnamed type>) _self, 0); } { struct __st_parameter_dt dt_parm.1; dt_parm.1.common.filename = "pr26038.f90"; dt_parm.1.common.line = 10; dt_parm.1.common.unit = 6; dt_parm.1.common.flags = 128; _gfortran_st_write (&dt_parm.1); { int4 D.801; D.801 = _self; _gfortran_transfer_integer (&dt_parm.1, &D.801, 4); } _gfortran_st_write_done (&dt_parm.1); } } MAIN__ () { char[1:10] * q; char[1:5] * p; foo (&p, 5); foo (&q, 10); } I will email Jakub to let him know. Perhaps the trick will be to apply his pre-gomp patch to 4.2 and mine to 4.1? Paul -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26038