[PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu May 10 15:57:00 GMT 2018
It is certainly possible to give a warning, but it
would be odd (to me) to warn about technically
standard conforming code. gfortran doesn't warn
for zero-sized array references or zero-length
substrings in other context.
program foo
real a(4)
character(len=10) s
s = '12345'
a = 1
print *, size(a(2:1)), len(s(3:2))
end program foo
% gfc -o z a.f90
% ./z
0 0
--
steve
On Thu, May 10, 2018 at 05:18:25PM +0200, Andre Vehreschild wrote:
> Hi Steve,
>
> the patch looks OK to me. Is it possible to give a warning
> there, at least with some higher warning-level? Or is there
> already one? I haven't tested it.
>
> Regards,
> Andre
>
> On Thu, 10 May 2018 07:15:21 -0700
> Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
>
> > On Thu, May 10, 2018 at 11:48:24AM +0200, Dominique d'Humières wrote:
> > > Hi Steve,
> > >
> > > AFAICT the patch is missing.
> > >
> > > Thanks for working on these PRs.
> > >
> >
> > Whoops. Looks like attached the log instead of diff.
> >
> > Index: gcc/fortran/array.c
> > ===================================================================
> > --- gcc/fortran/array.c (revision 259945)
> > +++ gcc/fortran/array.c (working copy)
> > @@ -2046,7 +2046,8 @@ got_charlen:
> > else
> > return true;
> >
> > - gcc_assert (current_length != -1);
> > + if (current_length < 0)
> > + current_length = 0;
> >
> > if (found_length == -1)
> > found_length = current_length;
> > Index: gcc/testsuite/gfortran.dg/pr85521_1.f90
> > ===================================================================
> > --- gcc/testsuite/gfortran.dg/pr85521_1.f90 (nonexistent)
> > +++ gcc/testsuite/gfortran.dg/pr85521_1.f90 (working copy)
> > @@ -0,0 +1,8 @@
> > +! { dg-do compile }
> > +! PR fortran/85521
> > +program p
> > + character(3) :: c = 'abc'
> > + character(3) :: z(1)
> > + z = [ c(:-1) ]
> > + print *, z
> > +end
> > Index: gcc/testsuite/gfortran.dg/pr85521_2.f90
> > ===================================================================
> > --- gcc/testsuite/gfortran.dg/pr85521_2.f90 (nonexistent)
> > +++ gcc/testsuite/gfortran.dg/pr85521_2.f90 (working copy)
> > @@ -0,0 +1,8 @@
> > +! { dg-do compile }
> > +! PR fortran/85521
> > +program p
> > + character(3) :: c = 'abc'
> > + character(3) :: z(1)
> > + z = [ c(:-2) ]
> > + print *, z
> > +end
> >
>
>
> --
> Andre Vehreschild * Email: vehre ad gmx dot de
--
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow
More information about the Gcc-patches
mailing list