[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-fortran
Subject: Re: Need a hint or more likely help
From: Steve Kargl <sgk () troutmask ! apl ! washington ! edu>
Date: 2024-02-12 3:14:34
Message-ID: ZcmNGnYdqpchJ-64 () troutmask ! apl ! washington ! edu
[Download RAW message or body]
On Sat, Feb 10, 2024 at 06:00:42PM -0800, Steve Kargl wrote:
> All, consider this simple code:
>
> module foo
> contains
> subroutine bar
> character(len=:), allocatable :: s(:)
> call bah(s)
> end subroutine bar
> end module foo
>
> If one compiles with -fdump-tree-original, one see (with some pruning)
>
> void bar ()
> {
> integer(kind=8) .s;
> struct array01_character(kind=1) s;
>
> The above two lines seem to be ok.
>
> bitsizetype D.4319;
> sizetype D.4320;
>
> try
> {
> D.4319 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.s> * 8;
> D.4320 = (sizetype) NON_LVALUE_EXPR <.s>;
> s.data = 0B;
> s.dtype = {.elem_len=(unsigned long) .s, .version=0, .rank=1, .type=6};
> bah ((character(kind=1)[0:][1:.s] * restrict) s.data, .s);
> }
>
> This is bad. .s is undefined. I've trace this to trans-array.cc:11531
I have created PR113883 with the patch suggested by Mikael and
a testcase. I have bootstrapped and regression tested the result.
Could I ask someone to commit it?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113883
* trans-array.cc (gfc_trans_deferred_array): Set length of an unallocated
character entity to zero to prevent reference to undefined variable.
* testsuite/gfortran.dg/allocatable_length.f90: New test.
--
Steve
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic