Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 28 Mar 2007 19:41:44 -0800
Brooks Moses wrote:
(snip)
Note that, in F2003, this will also apply to INT(z'FFFF8000'). It's not just something that happens with DATA statements.
I thought so, but tried it anyway.
Question to my fellow J3 Committee members: Did we really mean to outlaw this (it has an obvious meaning: stuff the 32 bits that FFFF8000 hex represents into a 32 bit integer and "damn the torpedo's".
g77 accepts it without even warning about it, so this probably means most compilers accept it (g77 was rather late to the game and, consequently, a follower of fashion).
I wouldn't mind it as a warning, especially if run time overflow
is not detected and trapped.
IIRC, g77 is doing rather weird things with it, actually, since it's interpreting the z'FFFF8000' as an integer constant and then converting it. I wouldn't be surprised to find that it's assigning it to an 8-byte integer and then simply wrapping it without throwing an error when it gets assigned to i.
My interpretation would be that the standard isn't, per se, outlawing this _as an extension_. The behavior when an integer is out of range is undefined, and I think it would not be amiss for a compiler to adjust its range-checking to allow for this usage as a special case, considering assignments from a BOZ-literal to an integer to be out of range only when there are too many bits.
It could even allow it when there are too many bits, as far as I know.
But, yeah, I would agree that this is a defect in the standard, that integer constants -- which are how most people store bitwise things! -- don't seem to follow the "treat BOZ-literals as a bitwise representation" rule.
I could argue both ways, but in terms of bitwise operations it makes
sense. I could probably live with -Z'00008000', too. It makes
less sense for bitwise operations, but for integer operations it will
work even for different BIT_SIZE, though only in twos complement.
I believe the only ones complement machines in production are 36 bit,
so in that case you lose twice.
-- glen
.
- Follow-Ups:
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Brooks Moses
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- References:
- BOZ literal constants, a puzzle for us Standard-loving types.
- From: Toon Moene
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Brooks Moses
- BOZ literal constants, a puzzle for us Standard-loving types.
- Prev by Date: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Next by Date: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Previous by thread: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Next by thread: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Index(es):
Relevant Pages
|