Re: ibits order. Was: Hollerith constants on a little endian machine
- From: harper@xxxxxxxxxxxxx (John Harper)
- Date: 19 Jan 2007 16:04:53 +1300
In article <eomp3j$gum$1@xxxxxxxxxxxxxxxxxxxxxxx>,
Steven G. Kargl <kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Looks like a quality of implementation issue with those compilers
because they are silently converted from one integer kind type
to another and ignoring the out-of-range value.
Apologies! I thought I had written a program to test ibits, but
Steven found that I had written one to test a bad DATA statement.
Do these compiler silent compile the following:
integer i
i = huge(i) + 1
print *, i
end
When I asked for no compiler options, all four f95 compilers (g95,
Sun, NAG, Compaq) objected to line 2 at compile time. But that error
is easy for compilers to find because huge(i) + 1 is a constant. The
following program tests what happens with integer overflow in a way
that's impossible to detect at compile time, and all four compilers
compiled and ran it with no error messages (again, no compiler options
were asked for):
INTEGER:: input, itested, iloop
PRINT *, "Enter an integer e.g. 1"
READ *, input
itested = huge(input) - input
DO iloop = 1,3
itested = itested + 1
PRINT "(1X,SP,I0)", itested
END DO
END
The result was the same in all four cases with input 1 :
Enter an integer e.g. 1
1
+2147483647
-2147483648
-2147483647
-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.
- References:
- Hollerith constants on a little endian machine
- From: robert . corbett
- Re: ibits order. Was: Hollerith constants on a little endian machine
- From: Steven G. Kargl
- Re: ibits order. Was: Hollerith constants on a little endian machine
- From: John Harper
- Re: ibits order. Was: Hollerith constants on a little endian machine
- From: Steven G. Kargl
- Hollerith constants on a little endian machine
- Prev by Date: Re: Many small programs vs. one large program?
- Next by Date: Re: run-time error M6101 : MATH
- Previous by thread: Re: ibits order. Was: Hollerith constants on a little endian machine
- Next by thread: Re: ibits order. Was: Hollerith constants on a little endian machine
- Index(es):
Relevant Pages
|