This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran, PR33254] Add -fbounds-checking for character array constructors
- From: dominiq at lps dot ens dot fr (Dominique Dhumieres)
- To: fortran at gcc dot gnu dot org
- Date: Sun, 14 Oct 2007 14:22:39 +0200
- Subject: Re: [gfortran, PR33254] Add -fbounds-checking for character array constructors
I think there is still a problem:
[karma] f90/bug% cat bounds_check_10_db_1.f90
! { dg-do run }
! { dg-options "-fbounds-check" }
! { dg-shouldfail "Different CHARACTER lengths" }
! PR fortran/33254: No bounds checking for array constructors
program array_char
implicit none
character (len=2) :: x, y
character (len=2) :: z(3)
x = "a "
y = "cd"
z = [y(1:len(trim(x))), y(1:1), x(1:len(trim(x)))] ! should work
z = [trim(x), y(1:len(trim(y))), y(1:len(trim(x)))] ! should catch first error
end program array_char
! { dg-output "Different CHARACTER lengths .1/2. in array constructor" }
[karma] f90/bug% gfc -fbounds-check bounds_check_10_db_1.f90
[karma] f90/bug% a.out
At line 12 of file bounds_check_10_db_1.f90
Fortran runtime error: Different CHARACTER lengths (1/2) in array constructor
catches the error, but if I put y(1:len(trim(y))) as the first item,
it does not:
[karma] f90/bug% diff bounds_check_10_db_1.f90 bounds_check_10_db.f90
12c12
< z = [trim(x), y(1:len(trim(y))), y(1:len(trim(x)))] ! should catch first error
---
> z = [y(1:len(trim(y))), trim(x), y(1:len(trim(x)))] ! should catch first error
[karma] f90/bug% gfc -fbounds-check bounds_check_10_db.f90
[karma] f90/bug% a.out
[karma] f90/bug%
Am I alone to see that? If not, any idea about the reason?
TIA
Dominique