This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/77560] New: Redefinition of lower bound in explicit-shape dummy argument
- From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 11 Sep 2016 13:24:34 +0000
- Subject: [Bug fortran/77560] New: Redefinition of lower bound in explicit-shape dummy argument
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77560
Bug ID: 77560
Summary: Redefinition of lower bound in explicit-shape dummy
argument
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Target Milestone: ---
The following program segfaults:
subroutine foo(a,from,to)
integer :: from, to
real, dimension(from:to) :: a
from = from + 1
print *,a
end subroutine foo
program main
real, dimension(3) :: a
a = reshape([(i,i=1,3)],shape(a))
print *,a
call foo(a,1,3)
end program main
ig25@linux-fd1f:~/Krempel/Full> gfortran full.f90
ig25@linux-fd1f:~/Krempel/Full> ./a.out
1.00000000 2.00000000 3.00000000
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f5d3ec6d087 in ???
#1 0x7f5d3ec6df35 in ???
#2 0x7f5d3e18511f in ???
#3 0x400879 in ???
#4 0x400a2a in ???
#5 0x400a61 in ???
#6 0x7f5d3e171b04 in ???
#7 0x400718 in ???
at ../sysdeps/x86_64/start.S:122
#8 0xffffffffffffffff in ???
Speicherzugriffsfehler
Although bad style, this is legal.
5.1.2.5.1 of J3/04-007 says
If an explicit-shape array has bounds that are not initialization expressions,
the bounds, and hence shape, are determined at entry to the procedure by
evaluating the bounds expressions. The bounds of such an array are unaffected
by
the redefinition or undefinition of any variable during execution of the
procedure.