This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Integer changes mid-execution


On 11/03/2009 05:21 AM, Nishita Desai wrote:
On Tue, Nov 3, 2009 at 17:19, N.M. Maclaren<nmm1@cam.ac.uk> wrote:
On Nov 3 2009, Nishita Desai wrote:

What happens is that suddenly at the end of the third iteration, NPART changes value. Here is a gdb transcript:

Somewhere in the code you are executing, you are overwriting NPART.
That is usually due to a subscript being larger than the size of an
array, but there are many other possible causes.

Thanks for your reply Nick. You were right, that was the case. However, I don't understand why this should happen. I can understand if P(I,NPART) points to some garbage value, or that I shall get a segmentation fault. But why is the array index variable overwritten?

If memory is being overwritten beyond the extent of an array you likely will hit other variables that are stored in adjacent locations.


Try -fbounds-check when you compile. It may give you some interesting results.

Jerry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]