This is the mail archive of the gcc-patches@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]

Re: [Patch, fortran] PR83344 - Use of uninitialized memory with ASSOCIATE and strings


Hi Janne,

Please find attached a revised version of the patch that fixes all the
issues that I know of.

Regtests on FC27/x86_64 - OK for trunk?

I have also attached a test of all the failing cases in PR83975.
However, I believe that they are all included in other associate*.f*.

Cheers

Paul

2018-02-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/83344
    * resolve.c (resolve_assoc_var): Rearrange the logic for the
    determination of the character length of associate names. If
    the associate name is missing a length expression or the length
    expression is not a constant and the target is not a variable,
    make the associate name allocatable and deferred length.
    * trans-decl.c (gfc_get_symbol_decl): Null the character length
    backend_decl for deferred length associate names that are not
    variables. Set 'length' to gfc_index_zero_node for character
    associate names, whose character length is a PARM_DECL.

2018-02-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/83344
    * gfortran.dg/associate_22.f90: Enable commented out test.
    * gfortran.dg/associate_36.f90: New test.


On 18 February 2018 at 21:01, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Hi Janne and Thomas,
>
> 1) The patch is attached now - sorry!
>
> 2) The commented out part of associate_22.f90 is not yet fixed. I am
> working on it.
>
> 3) I will take a look at PR83975 tomorrow night.
>
> Paul
>
>
> On 18 February 2018 at 16:08, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
>> On Sun, Feb 18, 2018 at 5:48 PM, Paul Richard Thomas
>> <paul.richard.thomas@gmail.com> wrote:
>>> Bootstraps and regtests on FC27/x86_64 - OK for trunk?
>>
>> Hi,
>>
>> thanks for looking into this!
>>
>> 1. The patch itself is missing...
>>
>> 2. Could you uncomment the commented out part of associate_22.f90 and
>> check that the tree-original dump is sensible.
>>
>> 3. Same for the testcases posted to PR 83975. I suspect (err, hope)
>> that this patch would fix those as well. If so, please add that PR to
>> the ChangeLog entries as well.
>>
>>>
>>> Paul
>>>
>>> 2018-02-18  Paul Thomas  <pault@gcc.gnu.org>
>>>
>>>     PR fortran/83344
>>>     * resolve.c (resolve_assoc_var): Character associate names that
>>>     have no length expression that have variable targets and are
>>>     not deferred length have assumed length.
>>>     * trans-decl.c (gfc_get_symbol_decl): Set 'length' to
>>>     gfc_index_zero_node for character associate names, whose string
>>>     length is a PARM_DECL.
>>>
>>> 2018-02-18  Paul Thomas  <pault@gcc.gnu.org>
>>>
>>>     PR fortran/83344
>>>     * gfortran.dg/associate_36.f90: New test.
>>
>>
>>
>> --
>> Janne Blomqvist
>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

Attachment: submit.diff
Description: Text document

! { dg-do run }
!
! Checks that all the tests in PR83975 now work.
!
! Contributed by G Steinmetz  <gscfq@t-online.de>
!
  character(10) :: chr = "abcdefghij"
  call s1(chr)
  call s2(chr)
  call s3(chr)
  call s4(chr)
  call s5(chr)
contains
  subroutine s1(x)
    character(*) :: x
    associate (y => x)
      if (y .ne. "abcdefghij") stop 1
      y = "xyz    end"
    end associate
  end
  subroutine s2(x)
    character(*) :: x
    associate (y => [x])
      if (y(1) .ne. "xyz    end") stop 2
    end associate
  end
  subroutine s3(x)
    character(*) :: x
    associate (y => [x, x])
      if (any (y .ne. ["xyz    end","xyz    end"])) stop 3
    end associate
  end
  subroutine s4(x)
    character(*) :: x
    associate (y => x)
      y = "abc    end"
      if (y .ne. "abc    end") stop 4
    end associate
  end
  subroutine s5(x)
    character(*) :: x
    associate (y => x//x)
      if (y .ne. "abc    endabc    end") stop 5
    end associate
  end
end

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