Re: [PATCH] Fortran: fix string length for array constructors with type-spec [PR85547]

Harald Anlauf <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Am 05.01.26 um 10:53 PM schrieb Harald Anlauf:
> Am 05.01.26 um 10:06 PM schrieb Jerry D:
>> I just finished testing this. Looks OK to go.
>>
>> I did not see anything obviously wrong with this.
>>
>> Commit at your discretion.
>>
>> Jerry
> 
> Hi Jerry,
> 
> thanks for checking.  Unfortunately, I found a last-minute issue...
> 
> The following code was previously miscompiled and is now rejected:
> 
> program p
>    integer :: n = 2
>    call foo ([character(n) :: 'abc'])
> contains
>    subroutine foo (x)
>      character(*), intent(in) :: x(:)
>      print *, len(x)
>    end subroutine foo
> end
> 
> gcc-15 prints 3 instead of 2; gcc-16 with my patch does:
> 
> pr47425-xx.f90:3:36:
> 
>      3 |   call foo ([character(n) :: 'abc'])
>        |                                    ^
> Error: size of variable 'A.5' is too large
> 
> This is triggered by the hunk from trans-array.cc.
> I have to think a little bit longer how to proceed...

I have not yet succeeded in solving the puzzle with
clean translation of the variable-length constructor
for constant-length constant string elements.
I therefore plan to split this part into a part 1
that is the submitted one minus the trans-array.cc
part, and will continue to work on the remaining issues.

Cheers,
Harald
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.