[gfortran, committed] Fix PR 25577
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Tue Feb 7 23:54:00 GMT 2006
I've committed the fix Dale posted in the PR after the required testing under
the obviously correct rule together with a testcase, which only succeeds with
the patched compiler. The patch added a cast which is needed for the case
where the requested type is wider than a C int. I will commit this to 4.1 as
well in the next few days.
(I also adjusted the copyright date after diffing.)
- Tobi
Index: libgfortran/ChangeLog
===================================================================
--- libgfortran/ChangeLog (revision 110720)
+++ libgfortran/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2006-02-07 Dale Ranta <dir@lanl.gov>
+
+ PR fortran/25577
+ * intrinsics/mvbits.c: Shift '(TYPE)1' type when building 'lenmask'.
+
2006-02-07 Rainer Emrich <r.emrich@de.tecosim.com>
* intrinsics/c99_functions.c: Work around incompatible
Index: libgfortran/intrinsics/mvbits.c
===================================================================
--- libgfortran/intrinsics/mvbits.c (revision 110720)
+++ libgfortran/intrinsics/mvbits.c (working copy)
@@ -48,7 +48,7 @@ SUB_NAME (const TYPE *from, const GFC_IN
{
TYPE oldbits, newbits, lenmask;
- lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : (1 << *len) - 1;
+ lenmask = (*len == sizeof (TYPE)*8) ? ~(TYPE)0 : ((TYPE)1 << *len) - 1;
newbits = (((UTYPE)(*from) >> *frompos) & lenmask) << *topos;
oldbits = *to & (~(lenmask << *topos));
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 110720)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,7 +1,12 @@
+2006-02-07 Tobias Schlter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/25577
+ * gfortran.dg/mvbits_1.f90: New.
+
2006-02-07 Dirk Mueller <dmueller@suse.com>
- g++.dg/warn/Wdiv-by-zero.C: New test.
- g++.dg/warn/Wno-div-by-zero.C: New.
+ * g++.dg/warn/Wdiv-by-zero.C: New test.
+ * g++.dg/warn/Wno-div-by-zero.C: New.
2006-02-07 Jeff Law <law@redhat.com>
Index: gcc/testsuite/gfortran.dg/mvbits_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/mvbits_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/mvbits_1.f90 (revision 0)
@@ -0,0 +1,39 @@
+! PR 25577
+! MVBITS didn't work correctly for integer types wider than a C int
+! The testcase is based on the one Dale Ranta posted in the bug report
+implicit none
+integer(1) i1,j1
+integer(2) i2,j2
+integer(4) i4,j4
+integer(8) i8,j8
+integer ibits,n
+
+ibits=bit_size(1_1)
+do n=1,ibits
+ i1=-1
+ call mvbits(1_1, 0,n,i1,0)
+ j1=-1-2_1**n+2
+ if(i1.ne.j1)call abort
+enddo
+ibits=bit_size(1_2)
+do n=1,ibits
+ i2=-1
+ call mvbits(1_2, 0,n,i2,0)
+ j2=-1-2_2**n+2
+ if(i2.ne.j2)call abort
+enddo
+ibits=bit_size(1_4)
+do n=1,ibits
+ i4=-1
+ call mvbits(1_4, 0,n,i4,0)
+ j4=-1-2_4**n+2
+ if(i4.ne.j4)call abort
+enddo
+ibits=bit_size(1_8)
+do n=1,ibits
+ i8=-1
+ call mvbits(1_8, 0,n,i8,0)
+ j8=-1-2_8**n+2
+ if(i8.ne.j8)call abort
+enddo
+end
More information about the Gcc-patches
mailing list