https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119106
Bug ID: 119106
Summary: Crash with character array constructor + implicit loop
+ data from `parameter` variable
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: federico.perini at gmail dot com
Target Milestone: ---
Created attachment 60649
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60649&action=edit
Test program
A runtime error is triggered with all versions of gfortran on this valid code:
```
program char_param_array
implicit none
character, parameter :: p(5) = ['1','2','3','4','5']
character, save :: n(5) = ['1','2','3','4','5']
integer :: i(10),j
i = 4
print *, [(n(i(j)),j=1,10)] ! OK
print *, [(p(i(j)),j=1,10)] ! runtime out-of-bounds error
end program char_param_array
```
A slightly more refined test case is found at https://godbolt.org/z/ccroE47eh
(Compiler Explorer).
A runtime error from `-fcheck=bounds` shows an invalid loop variable, only if:
- Implicit loop inside an array constructor
- The character variable has the `parameter` attribute (no issue otherwise).
Best regards,
Federico