* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
@ 2018-05-10 9:49 Dominique d'Humières
2018-05-10 14:15 ` Steve Kargl
0 siblings, 1 reply; 8+ messages in thread
From: Dominique d'Humières @ 2018-05-10 9:49 UTC (permalink / raw)
To: Steve Kargl; +Cc: gfortran, gcc-patches
Hi Steve,
AFAICT the patch is missing.
Thanks for working on these PRs.
Dominique
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 9:49 [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors Dominique d'Humières
@ 2018-05-10 14:15 ` Steve Kargl
2018-05-10 15:18 ` Andre Vehreschild
0 siblings, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2018-05-10 14:15 UTC (permalink / raw)
To: Dominique d'Humières; +Cc: gfortran, gcc-patches
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
--
Steve
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 14:15 ` Steve Kargl
@ 2018-05-10 15:18 ` Andre Vehreschild
2018-05-10 15:41 ` Steve Kargl
0 siblings, 1 reply; 8+ messages in thread
From: Andre Vehreschild @ 2018-05-10 15:18 UTC (permalink / raw)
To: Steve Kargl; +Cc: Dominique d'Humières, gfortran, gcc-patches
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 15:18 ` Andre Vehreschild
@ 2018-05-10 15:41 ` Steve Kargl
2018-05-10 17:57 ` Thomas Koenig
2018-05-13 12:31 ` Andre Vehreschild
0 siblings, 2 replies; 8+ messages in thread
From: Steve Kargl @ 2018-05-10 15:41 UTC (permalink / raw)
To: Andre Vehreschild; +Cc: Dominique d'Humières, gfortran, gcc-patches
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 15:41 ` Steve Kargl
@ 2018-05-10 17:57 ` Thomas Koenig
2018-05-10 18:00 ` Steve Kargl
2018-05-13 12:31 ` Andre Vehreschild
1 sibling, 1 reply; 8+ messages in thread
From: Thomas Koenig @ 2018-05-10 17:57 UTC (permalink / raw)
To: sgk, Andre Vehreschild
Cc: Dominique d'Humières, gfortran, gcc-patches
Am 10.05.2018 um 17:41 schrieb Steve Kargl:
> It is certainly possible to give a warning, but it
> would be odd (to me) to warn about technically
> standard conforming code.
Maybe we could add
gfc_warning (0, "Standard-conforming code found, your code may run as
expected");
at the end of the compilation :-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 17:57 ` Thomas Koenig
@ 2018-05-10 18:00 ` Steve Kargl
0 siblings, 0 replies; 8+ messages in thread
From: Steve Kargl @ 2018-05-10 18:00 UTC (permalink / raw)
To: Thomas Koenig
Cc: Andre Vehreschild, Dominique d'Humières, gfortran, gcc-patches
On Thu, May 10, 2018 at 07:56:59PM +0200, Thomas Koenig wrote:
> Am 10.05.2018 um 17:41 schrieb Steve Kargl:
> > It is certainly possible to give a warning, but it
> > would be odd (to me) to warn about technically
> > standard conforming code.
>
> Maybe we could add
>
> gfc_warning (0, "Standard-conforming code found, your code may run as
> expected");
>
> at the end of the compilation :-)
Given the amount of nonstandard code gfortran has to cope with,
the above isn't a bad idea! Perhaps, we can also hand out
merit badges. :-)
--
Steve
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
2018-05-10 15:41 ` Steve Kargl
2018-05-10 17:57 ` Thomas Koenig
@ 2018-05-13 12:31 ` Andre Vehreschild
1 sibling, 0 replies; 8+ messages in thread
From: Andre Vehreschild @ 2018-05-13 12:31 UTC (permalink / raw)
To: Steve Kargl; +Cc: Dominique d'Humières, gfortran, gcc-patches
Hi,
sorry, I didn't get, that this is standard conforming. So go for it: Ok for
trunk and thanks for the patch.
- Andre
On Thu, 10 May 2018 08:41:21 -0700
Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> 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
>
--
Andre Vehreschild * Email: vehre ad gmx dot de
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors
@ 2018-05-09 22:30 Steve Kargl
0 siblings, 0 replies; 8+ messages in thread
From: Steve Kargl @ 2018-05-09 22:30 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
I paln to commit the attached patch on Saturday unless
someone objects.
2018-05-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85521
* array.c (gfc_resolve_character_array_constructor): Substrings
with upper bound smaller than lower bound are zero length strings.
2018-05-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85521
* gfortran.dg/pr85521_1.f90: New test.
* gfortran.dg/pr85521_2.f90: New test.
--
Steve
[-- Attachment #2: pr85521.log --]
[-- Type: text/plain, Size: 350 bytes --]
2018-05-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85521
* array.c (gfc_resolve_character_array_constructor): Substrings
with upper bound smaller than lower bound are zero length strings.
2018-05-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85521
* gfortran.dg/pr85521_1.f90: New test.
* gfortran.dg/pr85521_2.f90: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-05-13 12:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 9:49 [PATCH] PR fortran/85521 -- Zero length substrings in array aconstructors Dominique d'Humières
2018-05-10 14:15 ` Steve Kargl
2018-05-10 15:18 ` Andre Vehreschild
2018-05-10 15:41 ` Steve Kargl
2018-05-10 17:57 ` Thomas Koenig
2018-05-10 18:00 ` Steve Kargl
2018-05-13 12:31 ` Andre Vehreschild
-- strict thread matches above, loose matches on Subject: below --
2018-05-09 22:30 Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).