https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64854
Harald Anlauf <anlauf at gmx dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gmx dot de --- Comment #3 from Harald Anlauf <anlauf at gmx dot de> --- (In reply to Dominique d'Humieres from comment #1) > Well, you give wrong information to the compiler. How do expect it to handle > your mistake: in testsub -fcheck=bounds checks that n1<=i<=n2 which is the > case. What you ask for is a check that a(n1:n2) is inside a(1:10), AFAIK > such check is not implemented and I don't have any idea about how difficult > it is to implement it. valgrind detects this issue. I was expected that the address sanitizer is able to handle it, but I am getting linking errors on my system. > I am inclined to close tis PR as INVALID or WONTFIX. The right way to fix the problem is to fix the program by using an appropriate programming style. Writing real :: a(n1:) ! not: real :: a(n1:n2) one gets the expected check: At line 22 of file pr64854.f90 Fortran runtime error: Index '1048586' of dimension 1 of array 'a' above upper bound of 1048585 Backtrace for this error: + function testsub.3321 (0x80486A4) from file pr64854.f90 + in the main program from file pr64854.f90 + /lib/libc.so.6(__libc_start_main+0xf3) [0xb7424003] I also suggest to close the PR.