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]
Other format: [Raw text]

[gfortran] Off by one in VERIFY intrinsic.


The patch below fixes and off by one error in the VERIFY intrinsic.

Tested on i686-linux.
Applied to mainline.

Paul

2004-10-07  Paul Brook  <paul@codesourcery.com>

 * intrinsics/string_intrinsics.c (string_verify): Fix off by one
 error.
testsuite/
 * gfortran.dg/intrinsic_verify_1.f90: New test.

Index: intrinsics/string_intrinsics.c
===================================================================
RCS 
file: /var/cvsroot/gcc-cvs/gcc/libgfortran/intrinsics/string_intrinsics.c,v
retrieving revision 1.4
diff -u -p -r1.4 string_intrinsics.c
--- intrinsics/string_intrinsics.c 25 Aug 2004 00:14:07 -0000 1.4
+++ intrinsics/string_intrinsics.c 7 Oct 2004 20:00:06 -0000
@@ -346,17 +346,16 @@ string_verify (GFC_INTEGER_4 slen, const
 
   if (back)
     {
-      last =  0;
+      last = -1;
       start = slen - 1;
       delta = -1;
     }
   else
     {
-      last = slen - 1;
+      last = slen;
       start = 0;
       delta = 1;
     }
-  i = 0;
   for (; start != last; start += delta)
     {
       for (i = 0; i < setlen; i++)

Attachment: intrinsic_verify_1.f90
Description: Text document


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