public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
@ 2020-06-04 18:16 gscfq@t-online.de
2020-06-04 18:17 ` [Bug fortran/95544] " gscfq@t-online.de
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2020-06-04 18:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
Bug ID: 95544
Summary: ICE in gfc_can_put_var_on_stack, at
fortran/trans-decl.c:494
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Affects versions down to at least r5 :
$ cat z1.f90
program p
character(:), allocatable :: z
print *, adjustl(null(z))
print *, adjustr(null(z))
end
$ cat z2.f90
program p
character(:), pointer :: z
print *, adjustl(null(z))
print *, adjustr(null(z))
end
$ gfortran-11-20200531 -c z1.f90
z1.f90:3:0:
3 | print *, adjustl(null(z))
|
internal compiler error: Segmentation fault
0xbc37bf crash_signal
../../gcc/toplev.c:328
0x720000 gfc_can_put_var_on_stack(tree_node*)
../../gcc/fortran/trans-decl.c:494
0x72edb8 gfc_conv_string_tmp(gfc_se*, tree_node*, tree_node*)
../../gcc/fortran/trans-expr.c:3378
0x745c66 gfc_conv_intrinsic_adjust
../../gcc/fortran/trans-intrinsic.c:8201
0x75ab1b gfc_conv_intrinsic_function(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-intrinsic.c:10038
0x73205a gfc_conv_expr(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:8682
0x738ef2 gfc_conv_expr_reference(gfc_se*, gfc_expr*, bool)
../../gcc/fortran/trans-expr.c:8782
0x761687 gfc_trans_transfer(gfc_code*)
../../gcc/fortran/trans-io.c:2582
0x7017f7 trans_code
../../gcc/fortran/trans.c:2084
0x75f16e build_dt
../../gcc/fortran/trans-io.c:2026
0x7017d7 trans_code
../../gcc/fortran/trans.c:2056
0x72ad24 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6840
0x6b25e6 translate_all_program_units
../../gcc/fortran/parse.c:6306
0x6b25e6 gfc_parse_file()
../../gcc/fortran/parse.c:6545
0x6fdfff gfc_be_parse_file
../../gcc/fortran/f95-lang.c:210
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
@ 2020-06-04 18:17 ` gscfq@t-online.de
2020-06-04 21:09 ` kargl at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2020-06-04 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
G. Steinmetz <gscfq@t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---
Related :
$ cat za1.f90
program p
character(:), allocatable :: z
print *, len(null(z))
print *, len_trim(null(z))
end
$ cat za2.f90
program p
character(:), pointer :: z
print *, len(null(z))
print *, len_trim(null(z))
end
$ cat zz1.f90
program p
character(:), allocatable :: z
z = trim(null(z))
end
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
2020-06-04 18:17 ` [Bug fortran/95544] " gscfq@t-online.de
@ 2020-06-04 21:09 ` kargl at gcc dot gnu.org
2020-06-04 21:27 ` kargl at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-04 21:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
CC| |kargl at gcc dot gnu.org
Last reconfirmed| |2020-06-04
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from kargl at gcc dot gnu.org ---
There may be a better (or more restrictive) test, but this cures the issues.
Index: gcc/fortran/intrinsic.c
===================================================================
--- gcc/fortran/intrinsic.c (revision 280157)
+++ gcc/fortran/intrinsic.c (working copy)
@@ -4428,6 +4428,19 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_
return false;
}
+ /* F2018, p. 328: An argument to an intrinsic procedure other than
+ ASSOCIATED, NULL, or PRESENT shall be a data object. A EXPR_NULL
+ is not a data object. */
+ if (actual->expr->expr_type == EXPR_NULL
+ && !(strcmp(gfc_current_intrinsic, "associated") == 0
+ || strcmp(gfc_current_intrinsic, "null") == 0
+ || strcmp(gfc_current_intrinsic, "present") == 0))
+ {
+ gfc_error ("NULL() at %L cannot appear as an actual argument in %qs",
+ &actual->expr->where, gfc_current_intrinsic);
+ return false;
+ }
+
/* If the formal argument is INTENT([IN]OUT), check for definability.
*/
if (formal->intent == INTENT_INOUT || formal->intent == INTENT_OUT)
{
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
2020-06-04 18:17 ` [Bug fortran/95544] " gscfq@t-online.de
2020-06-04 21:09 ` kargl at gcc dot gnu.org
@ 2020-06-04 21:27 ` kargl at gcc dot gnu.org
2020-06-04 23:06 ` sgk at troutmask dot apl.washington.edu
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-04 21:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #3 from kargl at gcc dot gnu.org ---
Updated patch to deal with comments #1.
Index: gcc/fortran/intrinsic.c
===================================================================
--- gcc/fortran/intrinsic.c (revision 280157)
+++ gcc/fortran/intrinsic.c (working copy)
@@ -4428,6 +4428,19 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_
return false;
}
+ /* F2018, p. 328: An argument to an intrinsic procedure other than
+ ASSOCIATED, NULL, or PRESENT shall be a data object. A EXPR_NULL
+ is not a data object. */
+ if (actual->expr->expr_type == EXPR_NULL
+ && !(strcmp(gfc_current_intrinsic, "associated") == 0
+ || strcmp(gfc_current_intrinsic, "null") == 0
+ || strcmp(gfc_current_intrinsic, "present") == 0))
+ {
+ gfc_error ("NULL() at %L cannot appear as an actual argument in %qs",
+ &actual->expr->where, gfc_current_intrinsic);
+ return false;
+ }
+
/* If the formal argument is INTENT([IN]OUT), check for definability.
*/
if (formal->intent == INTENT_INOUT || formal->intent == INTENT_OUT)
{
Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c (revision 280157)
+++ gcc/fortran/check.c (working copy)
@@ -3444,8 +3444,16 @@ gfc_check_len_lentrim (gfc_expr *s, gfc_expr *kind)
if (!type_check (s, 0, BT_CHARACTER))
return false;
+ if (s->expr_type == EXPR_NULL)
+ {
+ gfc_error ("Intrinsic function NULL at %L cannot be an actual "
+ "argument to %qs", &s->where, gfc_current_intrinsic);
+ return false;
+ }
+
if (!kind_check (kind, 1, BT_INTEGER))
return false;
+
if (kind && !gfc_notify_std (GFC_STD_F2003, "%qs intrinsic "
"with KIND argument at %L",
gfc_current_intrinsic, &kind->where))
@@ -6377,6 +6385,13 @@ gfc_check_trim (gfc_expr *x)
{
if (!type_check (x, 0, BT_CHARACTER))
return false;
+
+ if (x->expr_type == EXPR_NULL)
+ {
+ gfc_error ("Intrinsic function NULL at %L cannot be an actual "
+ "argument to %qs", &x->where, gfc_current_intrinsic);
+ return false;
+ }
if (!scalar_check (x, 0))
return false;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (2 preceding siblings ...)
2020-06-04 21:27 ` kargl at gcc dot gnu.org
@ 2020-06-04 23:06 ` sgk at troutmask dot apl.washington.edu
2020-06-08 20:02 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-06-04 23:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
Likely, want to include this in the commit if someone ever gets
around to committing the patch(es).
Index: gcc/fortran/misc.c
===================================================================
--- gcc/fortran/misc.c (revision 280157)
+++ gcc/fortran/misc.c (working copy)
@@ -252,7 +252,8 @@ gfc_dummy_typename (gfc_typespec *ts)
has_length = ts->u.cl->length != NULL;
if (!has_length)
{
- if (ts->kind == gfc_default_character_kind)
+ if (ts->kind == gfc_default_character_kind
+ || ts->kind == 0)
sprintf(buffer, "CHARACTER(*)");
else if (ts->kind < 10)
sprintf(buffer, "CHARACTER(*,%d)", ts->kind);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (3 preceding siblings ...)
2020-06-04 23:06 ` sgk at troutmask dot apl.washington.edu
@ 2020-06-08 20:02 ` anlauf at gcc dot gnu.org
2020-06-08 20:29 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-06-08 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #5 from anlauf at gcc dot gnu.org ---
Created attachment 48708
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48708&action=edit
Cleaned up patch
Hi Steve,
since there is already a function invalid_null_arg(), it can be reused.
If you do not object, I'll package it for you.
Regarding comment#4, please create a separate PR.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (4 preceding siblings ...)
2020-06-08 20:02 ` anlauf at gcc dot gnu.org
@ 2020-06-08 20:29 ` anlauf at gcc dot gnu.org
2020-06-08 20:35 ` sgk at troutmask dot apl.washington.edu
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-06-08 20:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #6 from anlauf at gcc dot gnu.org ---
Submitted for review here:
https://gcc.gnu.org/pipermail/fortran/2020-June/054499.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (5 preceding siblings ...)
2020-06-08 20:29 ` anlauf at gcc dot gnu.org
@ 2020-06-08 20:35 ` sgk at troutmask dot apl.washington.edu
2020-06-11 18:30 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-06-08 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Jun 08, 2020 at 08:02:48PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
>
> anlauf at gcc dot gnu.org changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |anlauf at gcc dot gnu.org
>
> --- Comment #5 from anlauf at gcc dot gnu.org ---
> Created attachment 48708
> --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48708&action=edit
> Cleaned up patch
>
> Hi Steve,
>
> since there is already a function invalid_null_arg(), it can be reused.
>
> If you do not object, I'll package it for you.
>
No problem. I was aware of invalid_null_arg(), but
simply copied a nearby gfc_error().
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (6 preceding siblings ...)
2020-06-08 20:35 ` sgk at troutmask dot apl.washington.edu
@ 2020-06-11 18:30 ` cvs-commit at gcc dot gnu.org
2020-06-14 12:58 ` cvs-commit at gcc dot gnu.org
2020-06-14 13:32 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-11 18:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:7fd614ee818983274eb5e47cbb8ec68b20994963
commit r11-1240-g7fd614ee818983274eb5e47cbb8ec68b20994963
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jun 11 20:29:45 2020 +0200
PR fortran/95544 - Fix ICE in NULL() argument to intrinsics
Fortran 2018: An argument to an intrinsic procedure other than ASSOCIATED,
NULL, or PRESENT shall be a data object. An EXPR_NULL is not a data
object. Add checks for intrinsics.
2020-06-11 Steven G. Kargl <kargl@gcc.gnu.org>
Harald Anlauf <anlauf@gmx.de>
gcc/fortran/
PR fortran/95544
* check.c (invalid_null_arg): Rename to gfc_invalid_null_arg.
(gfc_check_associated, gfc_check_kind, gfc_check_merge)
(gfc_check_shape, gfc_check_size, gfc_check_spread)
(gfc_check_transfer): Adjust.
(gfc_check_len_lentrim, gfc_check_trim): Check for NULL() argument.
* gfortran.h: Declare gfc_invalid_null_arg ().
* intrinsic.c (check_arglist): Check for NULL() argument.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (7 preceding siblings ...)
2020-06-11 18:30 ` cvs-commit at gcc dot gnu.org
@ 2020-06-14 12:58 ` cvs-commit at gcc dot gnu.org
2020-06-14 13:32 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-14 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:b0feef39fe53fbc46c22ac0c745f91dbf96cdd00
commit r10-8302-gb0feef39fe53fbc46c22ac0c745f91dbf96cdd00
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jun 11 20:29:45 2020 +0200
PR fortran/95544 - Fix ICE in NULL() argument to intrinsics
Fortran 2018: An argument to an intrinsic procedure other than ASSOCIATED,
NULL, or PRESENT shall be a data object. An EXPR_NULL is not a data
object. Add checks for intrinsics.
2020-06-11 Steven G. Kargl <kargl@gcc.gnu.org>
Harald Anlauf <anlauf@gmx.de>
gcc/fortran/
PR fortran/95544
* check.c (invalid_null_arg): Rename to gfc_invalid_null_arg.
(gfc_check_associated, gfc_check_kind, gfc_check_merge)
(gfc_check_shape, gfc_check_size, gfc_check_spread)
(gfc_check_transfer): Adjust.
(gfc_check_len_lentrim, gfc_check_trim): Check for NULL() argument.
* gfortran.h: Declare gfc_invalid_null_arg ().
* intrinsic.c (check_arglist): Check for NULL() argument.
(cherry picked from commit 7fd614ee818983274eb5e47cbb8ec68b20994963)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/95544] ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
` (8 preceding siblings ...)
2020-06-14 12:58 ` cvs-commit at gcc dot gnu.org
@ 2020-06-14 13:32 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-06-14 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95544
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on master for GCC-11, and backported to 10-branch along with the fix
for pr93366, which is a prerequisite for this one.
Backport to 9-branch would require additional work. Since this is not a
regression and an ICE on invalid, not done. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-06-14 13:32 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 18:16 [Bug fortran/95544] New: ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494 gscfq@t-online.de
2020-06-04 18:17 ` [Bug fortran/95544] " gscfq@t-online.de
2020-06-04 21:09 ` kargl at gcc dot gnu.org
2020-06-04 21:27 ` kargl at gcc dot gnu.org
2020-06-04 23:06 ` sgk at troutmask dot apl.washington.edu
2020-06-08 20:02 ` anlauf at gcc dot gnu.org
2020-06-08 20:29 ` anlauf at gcc dot gnu.org
2020-06-08 20:35 ` sgk at troutmask dot apl.washington.edu
2020-06-11 18:30 ` cvs-commit at gcc dot gnu.org
2020-06-14 12:58 ` cvs-commit at gcc dot gnu.org
2020-06-14 13:32 ` anlauf 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).