https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116254

--- Comment #14 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 59939
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59939&action=edit
Fix for this PR

(In reply to Richard Sandiford from comment #10)
Hi Richard,

The temporary array descriptor is initialized with a preset dtype field. The
class callers, such as the spread intrinsic, detect the nulled data field and
do the allocation and fill the dim fields appropriately. However, to prevent
complaints with -Wall, suppress_warning (desc) is set.

The attachment fixes the problem by ensuring that the class type and the array
descriptor are correct for the potential changes in rank. For what ever reason,
the spread intrinsic, alone among the other rank changes was not taking the
code path required for this. To make the code a bit more aesthetically pleasing
to you, I have changed the temporary array descriptor before it is assigned to
the class _data field :-) Thusly:

    b._vptr = a._vptr;
    D.5494 = b._vptr != 0B ? b._vptr->_size : 0;
        typedef character(kind=1) [0:][1:D.5494];
    ctmp.99._vptr = a._vptr;
    D.5511 = a._vptr->_size;
    atmp.98.dtype = a._data.dtype;
    atmp.98.dtype.rank = 2;
    ctmp.99._data = atmp.98;
    ctmp.99._data.span = D.5511;
    ctmp.99._data.data = 0B;
    ctmp.99._data.offset = 0;
    _gfortran_spread (&ctmp.99._data, D.5489, D.5491, D.5493);

Would you please verify that this patch fixes the bug for you?

Thanks

Paul

Reply via email to