Re: Question about out-of-bounds warning
- From: "FX" <coudert@xxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 21:16:04 +0000 (UTC)
program main
integer :: i(2)
i (0:-1) = 1
end
Interesting: neither gfortran (GNU Fortran 95 (GCC) 4.3.0 20061223
(experimental)) nor Sun's f95 (f95: Sun Fortran 95 8.2 Patch 121020-04
2006/10/26) throw an error and both binaries run without any problems;
Yes, and they have a reason to do so. i(0:-1) = 1 is perfectly legal, and
does nothing at all: it takes all the elements in the section 0:-1 of the
i array, which means "no element", and sets them to 1.
one difference occurs when I try to print "i": the Sun binary just
print zeroes while the gfortran binary prints random integers.
Well, it depends on the compiler, the OS, the moon and your karma. You're
reading uninitialized memory.
--
FX
.
- References:
- Question about out-of-bounds warning
- From: Thomas Koenig
- Re: Question about out-of-bounds warning
- From: Sebastian Hanigk
- Question about out-of-bounds warning
- Prev by Date: Re: Question about out-of-bounds warning
- Next by Date: Re: Declaration to get 8-bit (or 16-bit) integer?
- Previous by thread: Re: Question about out-of-bounds warning
- Next by thread: Re: Question about out-of-bounds warning
- Index(es):
Relevant Pages
|