causes for an invalid memory reference?
Steve Kargl
sgk@troutmask.apl.washington.edu
Mon Feb 25 00:33:00 GMT 2019
On Sun, Feb 24, 2019 at 12:57:10PM -0800, Damian Rouson wrote:
> Gfortran developers,
>
> Other than array indices out of bounds, could someone tell me what else
> could cause the error "Segmentation fault - invalid memory reference" in
> the following line?
>
> derivU(:,n+1) = sum( &
> [(PascalEntry(psn+k)*(derivU(:,n-k) .cross. derivB(:,k)),k=0,km)]&
> )
>
> where derivU, derivB, and PascalEntry are non-allocatable arrays declared
> with either module scope or submodule scope, none of the involved arrays,
> has the pointer attribute, and the .cross. operator refers to a pure function
> that computes the cross product from vector calculus. A bit more context is
> below. Just before the problematic line, there is code (not shown below)
> that verifies that the values used in all array indices are within bounds.
>
Clever uses of an implied-do-loop can cause very difficult to
fix bugs (either in one's code or a compiler). I suspect that
you're getting one (or more) temporary array(s) with issues
with the bounds. Using -fdump-tree-original might shed some
light on how the implied-do-loop and the user defined operator
are interacting.
--
Steve
More information about the Fortran
mailing list