http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43310
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #14 from kargl at gcc dot gnu.org 2010-11-03 17:33:59 UTC ---
(In reply to comment #13)
> (In reply to comment #11)
> > > Well, the number model is symmetric. See Fortran 2003 ...
> >
> > I agree, but it is a very pedantic view that should at least be mentioned in
> > the manual.
>
> You forgot to attach your patch.
>
> > Now I think the implementation is not consistent:
> >
> > [macbook] f90/bug% cat > ishft_1.f90
> > print *, ishft(1,31)
> > end
> > [macbook] f90/bug% gfc -Wall -pedantic ishft_1.f90
> > [macbook] f90/bug% a.out
> > -2147483648
>
> gfc_simplify_ishft doesn't range check its result.
> Patch welcomed.
laptop:kargl[210] gfc4x -o z t.f90
laptop:kargl[211] ./z
-2147483648
laptop:kargl[212] gfc4x -o z -pedantic t.f90
t.f90:1.14:
print*, ishft(1,31)
1
Error: Result of ISHFT gives range error for its kind at (1)
Index: simplify.c
===================================================================
--- simplify.c (revision 166091)
+++ simplify.c (working copy)
@@ -3002,7 +3002,7 @@ simplify_shift (gfc_expr *e, gfc_expr *s
convert_mpz_to_signed (result->value.integer, bitsize);
gfc_free (bits);
- return result;
+ return range_check (result, name);
}