This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/49324] Deep copy missing for array constructors of DT w/ allocatable components


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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-10 08:35:02 UTC ---
(In reply to comment #5)
> The following should partially help

It does - but it also leads to two test suite failures:
  gfortran.dg/alloc_comp_assign_5.f90 - failure around line 53. Output:
      "if (ctr /= 1) call abort ()"
    fails as ctr is 5 instead of 1
  gfortran.dg/alloc_comp_assign_6.f90
    "ERROR: should be ef, got: AA           2"

Thus, the patch of comment 5 should be scratched. Next try: Use in the argument
"|| expr_type == EXPR_ARRAY" (in gfc_conv_expr_descriptor and
gfc_trans_assignment_1), which seems to work.

 * * *

The realloc on assignment still does not work: I get a segfault for the simple
example:

  type t
    integer, allocatable :: A(:)
  end type t
  type(t) :: x
  type(t), allocatable :: z(:)
  print *, "(1)"
  z = [ x ]
  print *, "(2)"
  print *, allocated(z)
  end

Excerpt (from the optimized dump):
  D.1622_32 = __builtin_malloc (48);
  SR.15_179 = MEM[(struct t[0:] *)D.1622_33].data;

[...]

<bb 12>:
  if (SR.15_179 != 0B)
    goto <bb 6>;

The problem is: D.1622_33.data is never set. Depending on the malloc
implementation, the returned memory may or may not be filled with NULL. If one
forces that the returned memory is NULL, it works (by chance), if not, one gets
- like I do - a segfault. Also valgrind shows a "Conditional jump or move
depends on uninitialised value" warning.

 * * *

For RESHAPE, gfortran seems to be a nontrivial bug: While the argument contains
the allocatable components, one simply calls:

          _gfortran_reshape (&D.1662, D.1685, D.1691, 0B, 0B);

And for obvious reasons, doing reshape does not know anything about allocatable
components and does only a shallow copy:
   memcpy(rptr, src, size);

The solution is presumably to do a normal assignment - and only modify the
shape in _gfortran_reshape.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]