public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514
@ 2021-10-11 17:06 gscfq@t-online.de
2021-10-11 17:07 ` [Bug fortran/102685] " gscfq@t-online.de
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: gscfq@t-online.de @ 2021-10-11 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
Bug ID: 102685
Summary: [12 Regression] ICE in
output_constructor_regular_field, at varasm.c:5514
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Changed _recently_ between 20211003 and 20211010 :
$ cat z1.f90
program p
type t
integer :: a(1)
end type
type(t), parameter :: x(2) = t([1,2])
print *, x
end
$ gfortran-12-20211003 -c z1.f90
$
$ gfortran-12-20211010 -c z1.f90
z1.f90:7:3:
7 | end
| ^
internal compiler error: in output_constructor_regular_field, at varasm.c:5514
0x10131f4 output_constructor_regular_field
../../gcc/varasm.c:5514
0x10131f4 output_constructor
../../gcc/varasm.c:5826
0x101353f output_constant
../../gcc/varasm.c:5172
0x101353f assemble_variable_contents
../../gcc/varasm.c:2235
0x101b31d assemble_variable(tree_node*, int, int, int)
../../gcc/varasm.c:2414
0x101d61a varpool_node::assemble_decl()
../../gcc/varpool.c:595
0x953def output_in_order
../../gcc/cgraphunit.c:2135
0x953def symbol_table::compile()
../../gcc/cgraphunit.c:2353
0x95670f symbol_table::compile()
../../gcc/cgraphunit.c:2540
0x95670f symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
@ 2021-10-11 17:07 ` gscfq@t-online.de
2021-10-11 17:39 ` anlauf at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: gscfq@t-online.de @ 2021-10-11 17:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
G. Steinmetz <gscfq@t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid,
| |ice-on-invalid-code
--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---
This invalid variant is still accepted :
(also related to pr100970)
$ cat z2.f90
program p
type t
integer :: a(1)
end type
type(t) :: x(2) = t([1,2])
print *, x
end
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
2021-10-11 17:07 ` [Bug fortran/102685] " gscfq@t-online.de
@ 2021-10-11 17:39 ` anlauf at gcc dot gnu.org
2021-10-11 21:51 ` anlauf at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-11 17:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Priority|P3 |P4
Last reconfirmed| |2021-10-11
Ever confirmed|0 |1
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
That's arguably a regression.
gcc-11 accepted the invalid testcase in comment#0 but generated wrong code.
The real reason is that the constructor is not dealth with properly,
and there are several related PRs I am too lazy to look up now.
The accepts-invalid for comment#1 is old and not a regression for that reason.
gcc-7 had that already, and maybe much longer.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
2021-10-11 17:07 ` [Bug fortran/102685] " gscfq@t-online.de
2021-10-11 17:39 ` anlauf at gcc dot gnu.org
@ 2021-10-11 21:51 ` anlauf at gcc dot gnu.org
2021-10-12 6:19 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-11 21:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
--- Comment #3 from anlauf at gcc dot gnu.org ---
Preliminary patch (untested):
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 0d0af39d23f..c5df42ba67a 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1333,6 +1333,31 @@ resolve_structure_cons (gfc_expr *expr, int init)
t = false;
}
+ /* Validate shape. */
+ if (cons->expr->expr_type == EXPR_ARRAY && rank == cons->expr->rank
+ && !(comp->attr.allocatable || comp->attr.pointer))
+ {
+ mpz_t tmp;
+ int n;
+ mpz_init (tmp);
+ for (n = 0; n < rank; n++)
+ {
+ mpz_set_ui (tmp, 1);
+ mpz_add (tmp, tmp, comp->as->upper[n]->value.integer);
+ mpz_sub (tmp, tmp, comp->as->lower[n]->value.integer);
+ if (mpz_cmp (cons->expr->shape[n], tmp) != 0)
+ {
+ gfc_error ("The shape of a component in the structure "
+ "constructor at %L differs from the shape of the "
+ "declared component (%ld/%ld)",
&cons->expr->where,
+ mpz_get_si (cons->expr->shape[n]),
+ mpz_get_si (tmp));
+ t = false;
+ }
+ }
+ mpz_clear (tmp);
+ }
+
/* If we don't have the right type, try to convert it. */
if (!comp->attr.proc_pointer &&
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (2 preceding siblings ...)
2021-10-11 21:51 ` anlauf at gcc dot gnu.org
@ 2021-10-12 6:19 ` rguenth at gcc dot gnu.org
2021-10-12 12:45 ` [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79 marxin at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-12 6:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (3 preceding siblings ...)
2021-10-12 6:19 ` rguenth at gcc dot gnu.org
@ 2021-10-12 12:45 ` marxin at gcc dot gnu.org
2021-10-14 21:27 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-12 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Summary|[12 Regression] ICE in |[12 Regression] ICE in
|output_constructor_regular_ |output_constructor_regular_
|field, at varasm.c:5514 |field, at varasm.c:5514
| |since
| |r12-4278-g74ccca380cde5e79
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Btw. started with r12-4278-g74ccca380cde5e79.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (4 preceding siblings ...)
2021-10-12 12:45 ` [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79 marxin at gcc dot gnu.org
@ 2021-10-14 21:27 ` anlauf at gcc dot gnu.org
2021-10-15 19:23 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-14 21:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
--- Comment #5 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2021-October/056724.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (5 preceding siblings ...)
2021-10-14 21:27 ` anlauf at gcc dot gnu.org
@ 2021-10-15 19:23 ` cvs-commit at gcc dot gnu.org
2021-10-24 19:09 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-15 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
--- Comment #6 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:1e819bd95ebeefc1dc469daa1855ce005cb77822
commit r12-4452-g1e819bd95ebeefc1dc469daa1855ce005cb77822
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Oct 15 21:23:17 2021 +0200
Fortran: validate shape of arrays in constructors against declarations
gcc/fortran/ChangeLog:
PR fortran/102685
* decl.c (match_clist_expr): Set rank/shape of clist initializer
to match LHS.
* resolve.c (resolve_structure_cons): In a structure constructor,
compare shapes of array components against declared shape.
gcc/testsuite/ChangeLog:
PR fortran/102685
* gfortran.dg/derived_constructor_char_1.f90: Fix invalid code.
* gfortran.dg/pr70931.f90: Likewise.
* gfortran.dg/transfer_simplify_2.f90: Likewise.
* gfortran.dg/pr102685.f90: New test.
Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (6 preceding siblings ...)
2021-10-15 19:23 ` cvs-commit at gcc dot gnu.org
@ 2021-10-24 19:09 ` anlauf at gcc dot gnu.org
2021-10-24 19:15 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-24 19:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gerhard.steinmetz.fortran@t
| |-online.de
--- Comment #7 from anlauf at gcc dot gnu.org ---
*** Bug 67542 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (7 preceding siblings ...)
2021-10-24 19:09 ` anlauf at gcc dot gnu.org
@ 2021-10-24 19:15 ` anlauf at gcc dot gnu.org
2021-11-07 20:54 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-24 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
--- Comment #8 from anlauf at gcc dot gnu.org ---
*** Bug 100970 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (8 preceding siblings ...)
2021-10-24 19:15 ` anlauf at gcc dot gnu.org
@ 2021-11-07 20:54 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:19 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-07 20:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:b1cab51131ad4d5501bf3f01e694704142a10c1a
commit r11-9216-gb1cab51131ad4d5501bf3f01e694704142a10c1a
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Oct 15 21:23:17 2021 +0200
Fortran: validate shape of arrays in constructors against declarations
gcc/fortran/ChangeLog:
PR fortran/102685
* decl.c (match_clist_expr): Set rank/shape of clist initializer
to match LHS.
* resolve.c (resolve_structure_cons): In a structure constructor,
compare shapes of array components against declared shape.
gcc/testsuite/ChangeLog:
PR fortran/102685
* gfortran.dg/derived_constructor_char_1.f90: Fix invalid code.
* gfortran.dg/pr70931.f90: Likewise.
* gfortran.dg/transfer_simplify_2.f90: Likewise.
* gfortran.dg/pr102685.f90: New test.
Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
(cherry picked from commit 1e819bd95ebeefc1dc469daa1855ce005cb77822)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (9 preceding siblings ...)
2021-11-07 20:54 ` cvs-commit at gcc dot gnu.org
@ 2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:19 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-13 20:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
--- Comment #10 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:e2c1283a5c9505257df3cf7a4b42758ef52ea674
commit r10-10270-ge2c1283a5c9505257df3cf7a4b42758ef52ea674
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Oct 15 21:23:17 2021 +0200
Fortran: validate shape of arrays in constructors against declarations
gcc/fortran/ChangeLog:
PR fortran/102685
* decl.c (match_clist_expr): Set rank/shape of clist initializer
to match LHS.
* resolve.c (resolve_structure_cons): In a structure constructor,
compare shapes of array components against declared shape.
gcc/testsuite/ChangeLog:
PR fortran/102685
* gfortran.dg/derived_constructor_char_1.f90: Fix invalid code.
* gfortran.dg/pr70931.f90: Likewise.
* gfortran.dg/transfer_simplify_2.f90: Likewise.
* gfortran.dg/pr102685.f90: New test.
Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
(cherry picked from commit 1e819bd95ebeefc1dc469daa1855ce005cb77822)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
` (10 preceding siblings ...)
2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
@ 2021-11-13 20:19 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-13 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102685
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and on 11- and 10-branch. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-11-13 20:19 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 17:06 [Bug fortran/102685] New: [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 gscfq@t-online.de
2021-10-11 17:07 ` [Bug fortran/102685] " gscfq@t-online.de
2021-10-11 17:39 ` anlauf at gcc dot gnu.org
2021-10-11 21:51 ` anlauf at gcc dot gnu.org
2021-10-12 6:19 ` rguenth at gcc dot gnu.org
2021-10-12 12:45 ` [Bug fortran/102685] [12 Regression] ICE in output_constructor_regular_field, at varasm.c:5514 since r12-4278-g74ccca380cde5e79 marxin at gcc dot gnu.org
2021-10-14 21:27 ` anlauf at gcc dot gnu.org
2021-10-15 19:23 ` cvs-commit at gcc dot gnu.org
2021-10-24 19:09 ` anlauf at gcc dot gnu.org
2021-10-24 19:15 ` anlauf at gcc dot gnu.org
2021-11-07 20:54 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:19 ` 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).