This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: [g77 testsuite]


On Wed, Jul 18, 2001 at 10:23:22PM +0200, Toon Moene wrote:
> So I think
> 
>       INTEGER I
>       I = 1
>       IF (ISHFT(I, BIT_SIZE(I)) .NE. 0) CALL ABORT
>       I = 0
>       IF (ISHFT(NOT(I), -BIT_SIZE(I)) .NE. 0) CALL ABORT
>       END
> 
> would test for this consistency (and mutatis mutandis for
> INTEGER*{1|2|8}).
> 
> The nice thing is - this actually fails for i686-pc-linux-gnu (and
> probably a lot of other targets).

It fails because in C, a shift larger than the operand size is
undefined, and the rtl shift operators inherit that.  This is a
Good Thing, because that's how most hardware actually works.

If such overflow is defined in Fortran, the front end will have
to add extra code for this.

That said, I think a better test is

	I = 0
	I = NOT(I)
	IF (ISHIFT(I, -BIT_SIZE(I)+1) .NE. 1) CALL ABORT
	I = 1
	I = ISHIFT(I, BIT_SIZE(I)-1)
	IF (I .EQ. 0) CALL ABORT
	IF (ISHIFT(I, 1) .NE. 0) CALL ABORT

since your test checks that BIT_SIZE is at least as large
as the integer, but doesn't check that it is not larger.


r~


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