public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67987] New: ICE on declaring and initializing character with negative len
@ 2015-10-16 14:08 gerhard.steinmetz.fortran@t-online.de
2015-10-16 17:01 ` [Bug fortran/67987] " kargl at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-10-16 14:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
Bug ID: 67987
Summary: ICE on declaring and initializing character with
negative len
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gerhard.steinmetz.fortran@t-online.de
Target Milestone: ---
Declaring and initializing a character with negative len (< -1)
requests memory of about 2^64 (= 18446744073709551616) :
$ cat z1.f90
program p
character(-8) :: c = ' '
end
$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z1.f90
f951: out of memory allocating 18446744073709551588 bytes after a total of
434176 bytes
---
Warning without assignment :
$ cat z2.f90
program p
character(-8) :: c
end
$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z2.f90
z2.f90:2:13:
character(-8) :: c
1
Warning: CHARACTER variable at (1) has negative length -8, the length has been
set to zero [-Wsurprising]
---
With len = -1, reaction depends on used compiler options :
$ cat z3.f90
program p
character(-1) :: c = 'c'
end
$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z3.f90
gfortran: internal compiler error: Segmentation fault (program f951)
---
Same issue with "character parameter".
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
@ 2015-10-16 17:01 ` kargl at gcc dot gnu.org
2015-10-16 18:03 ` kargl at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-16 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-10-16
CC| |kargl at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |kargl at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.6.4, 4.7.4, 4.8.5, 4.9.4,
| |5.2.1, 6.0
--- Comment #1 from kargl at gcc dot gnu.org ---
I have a patch that I'm testing. For the code in the
intial report I get
troutmask:sgk[238] gfc6 -c g6.f90
g6.f90:2:15:
character(-8) :: c = ' '
1
Error: LEN at (1) must be greater than or equal to 0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
2015-10-16 17:01 ` [Bug fortran/67987] " kargl at gcc dot gnu.org
@ 2015-10-16 18:03 ` kargl at gcc dot gnu.org
2015-10-16 18:31 ` sgk at troutmask dot apl.washington.edu
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-16 18:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> I have a patch that I'm testing. For the code in the
> intial report I get
>
> troutmask:sgk[238] gfc6 -c g6.f90
> g6.f90:2:15:
>
> character(-8) :: c = ' '
> 1
> Error: LEN at (1) must be greater than or equal to 0
Seems the patch causes a regression for char_length_2.f90.
This test came in with the fix for PR fortran/31250, where
negative length parameters are silently set to 0. The
fix for this regression is in resolve.c. Unfortnately,
this fix then exposes an issue with substring referecences.
For "string"(1:-1), this should result in a 0 length string,
but gfortran is setting the length to -1 in
gfc_resolve_substring_charlen.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
2015-10-16 17:01 ` [Bug fortran/67987] " kargl at gcc dot gnu.org
2015-10-16 18:03 ` kargl at gcc dot gnu.org
@ 2015-10-16 18:31 ` sgk at troutmask dot apl.washington.edu
2015-10-16 19:16 ` kargl at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-10-16 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Oct 16, 2015 at 06:03:06PM +0000, kargl at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
>
> --- Comment #2 from kargl at gcc dot gnu.org ---
> (In reply to kargl from comment #1)
> > I have a patch that I'm testing. For the code in the
> > intial report I get
> >
> > troutmask:sgk[238] gfc6 -c g6.f90
> > g6.f90:2:15:
> >
> > character(-8) :: c = ' '
> > 1
> > Error: LEN at (1) must be greater than or equal to 0
>
> Seems the patch causes a regression for char_length_2.f90.
> This test came in with the fix for PR fortran/31250, where
> negative length parameters are silently set to 0. The
> fix for this regression is in resolve.c. Unfortnately,
> this fix then exposes an issue with substring referecences.
> For "string"(1:-1), this should result in a 0 length string,
> but gfortran is setting the length to -1 in
> gfc_resolve_substring_charlen.
>
Go the substring issued ironed out.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
` (2 preceding siblings ...)
2015-10-16 18:31 ` sgk at troutmask dot apl.washington.edu
@ 2015-10-16 19:16 ` kargl at gcc dot gnu.org
2015-10-17 16:51 ` kargl at gcc dot gnu.org
2015-10-19 18:17 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-16 19:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
--- Comment #4 from kargl at gcc dot gnu.org ---
*** Bug 67988 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
` (3 preceding siblings ...)
2015-10-16 19:16 ` kargl at gcc dot gnu.org
@ 2015-10-17 16:51 ` kargl at gcc dot gnu.org
2015-10-19 18:17 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-17 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Sat Oct 17 16:50:47 2015
New Revision: 228933
URL: https://gcc.gnu.org/viewcvs?rev=228933&root=gcc&view=rev
Log:
2015-10-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67987
* decl.c (char_len_param_value): Unwrap unlong line. If LEN < 0,
force it to zero per the Fortran 90, 95, 2003, and 2008 Standards.
* resolve.c (gfc_resolve_substring_charlen): Unwrap unlong line.
If 'start' is larger than 'end', length of substring is negative,
so explicitly set it to zero.
(resolve_charlen): Remove -Wsurprising warning. Update comment to
reflect that the text is from the F2008 standard.
2015-10-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67987
* gfortran.df/pr67987.f90: New test.
* gfortran.dg/char_length_2.f90: Update testcase.
Added:
trunk/gcc/testsuite/gfortran.dg/pr67987.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/char_length_2.f90
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/67987] ICE on declaring and initializing character with negative len
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
` (4 preceding siblings ...)
2015-10-17 16:51 ` kargl at gcc dot gnu.org
@ 2015-10-19 18:17 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-19 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67987
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |5.3
--- Comment #7 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch. Thanks for the bug report.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-19 18:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16 14:08 [Bug fortran/67987] New: ICE on declaring and initializing character with negative len gerhard.steinmetz.fortran@t-online.de
2015-10-16 17:01 ` [Bug fortran/67987] " kargl at gcc dot gnu.org
2015-10-16 18:03 ` kargl at gcc dot gnu.org
2015-10-16 18:31 ` sgk at troutmask dot apl.washington.edu
2015-10-16 19:16 ` kargl at gcc dot gnu.org
2015-10-17 16:51 ` kargl at gcc dot gnu.org
2015-10-19 18:17 ` kargl at gcc dot gnu.org
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).