re PR libfortran/17164 (index function not working properly)

2004-08-24  Bud Davis  <bdavis9659@comcast.net>

        PR fortran/17164
        * runtime/string_intrinsics.c (string_index):check for
        substring longer than string.
        * gfortran.dg/pr17164.f90: New test.

From-SVN: r86527
This commit is contained in:
Bud Davis 2004-08-25 00:14:07 +00:00 committed by Bud Davis
parent 1e19ac749d
commit 02d735f6bd
4 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-08-24 Bud Davis <bdavis9659@comcast.net>
PR fortran/17164
* gfortran.dg/pr17164.f90: New test.
2004-08-24 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> 2004-08-24 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* gcc.dg/tree-ssa/loop-1.c: New test. * gcc.dg/tree-ssa/loop-1.c: New test.

View File

@ -0,0 +1,10 @@
! pr17164
! index aborts when substring is longer than string
implicit none
character*5 x
integer i
x='12345'
i=index(x,'blablabl')
if (i.ne.0) call abort
end

View File

@ -1,3 +1,9 @@
2004-08-24 Bud Davis <bdavis9659@comcast.net>
PR fortran/17164
* runtime/string_intrinsics.c (string_index):check for
substring longer than string.
2004-08-24 David Edelsohn <edelsohn@gnu.org> 2004-08-24 David Edelsohn <edelsohn@gnu.org>
* Makefile.am (libgfortran_la_LDFLAGS): Add -lm. * Makefile.am (libgfortran_la_LDFLAGS): Add -lm.

View File

@ -221,6 +221,9 @@ string_index (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 sslen,
if (sslen == 0) if (sslen == 0)
return 1; return 1;
if (sslen > slen)
return 0;
if (!back) if (!back)
{ {
last = slen + 1 - sslen; last = slen + 1 - sslen;