public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
@ 2022-09-27 16:19 gscfq@t-online.de
  2022-09-27 16:20 ` [Bug fortran/107054] " gscfq@t-online.de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2022-09-27 16:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

            Bug ID: 107054
           Summary: [10/11/12/13 Regression] ICE in gfc_simplify_unpack,
                    at fortran/simplify.cc:8461
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Starts with r10, originally with r12 between 20211003 and 20211010 :


$ cat z1.f90
program p
   type t
      integer :: n = 0
   end type
   type(t), parameter :: a(4) = t(2)
   type(t), parameter :: b(4) = reshape(a,[2])
   type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.])
   type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],a)
end


$ cat z2.f90
program p
   type t
      integer :: n = 0
   end type
   type(t), parameter :: a(2) = t(2)
   type(t), parameter :: b(4) = reshape(a,[2])
   type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.])
   type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],a)
end


$ cat z3.f90
program p
   type t
      integer :: n = 0
   end type
   type(t), parameter :: a(2,2) = t(2)
   type(t), parameter :: b(4) = reshape(a,[2])
   type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.])
   type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],b)
end


$ cat z4.f90
module m
   type t
      integer :: n
   end type
   type(t), parameter :: a(4) = t(1)
   type(t), parameter :: b(4) = t(2)
   type(t), parameter :: c(2) = pack (b, [.false., .false., .false., .true.])
   type(t), parameter :: d(4) = unpack (c, [.false., .true., .false., .true.],
a)
end


$ gfortran-9 -c z1.f90
z1.f90:6:29:

    6 |    type(t), parameter :: b(4) = reshape(a,[2])
      |                             1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)


$ gfortran-13-20220925 -c z1.f90
f951: internal compiler error: in gfc_simplify_unpack, at
fortran/simplify.cc:8461
0x891bbf gfc_simplify_unpack(gfc_expr*, gfc_expr*, gfc_expr*)
        ../../gcc/fortran/simplify.cc:8461
0x80a50a do_simplify
        ../../gcc/fortran/intrinsic.cc:4677
0x81549a gfc_intrinsic_func_interface(gfc_expr*, int)
        ../../gcc/fortran/intrinsic.cc:5056
0x86ab38 resolve_unknown_f
        ../../gcc/fortran/resolve.cc:2990
0x86ab38 resolve_function
        ../../gcc/fortran/resolve.cc:3347
0x86ab38 gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.cc:7194
0x7fa394 gfc_reduce_init_expr(gfc_expr*)
        ../../gcc/fortran/expr.cc:3164
0x7fd320 gfc_match_init_expr(gfc_expr**)
        ../../gcc/fortran/expr.cc:3212
0x7e72bb variable_decl
        ../../gcc/fortran/decl.cc:3028
0x7e72bb gfc_match_data_decl()
        ../../gcc/fortran/decl.cc:6331
0x852f83 match_word
        ../../gcc/fortran/parse.cc:67
0x852f83 decode_statement
        ../../gcc/fortran/parse.cc:378
0x8549ca next_free
        ../../gcc/fortran/parse.cc:1399
0x8549ca next_statement
        ../../gcc/fortran/parse.cc:1631
0x855f6b parse_spec
        ../../gcc/fortran/parse.cc:4170
0x85912c parse_progunit
        ../../gcc/fortran/parse.cc:6212
0x85a7f1 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6757
0x8a925f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:229

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
@ 2022-09-27 16:20 ` gscfq@t-online.de
  2022-09-27 18:02 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2022-09-27 16:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

G. Steinmetz <gscfq@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code

--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---

For reference :

$ cat z0.f90
program p
   type t
      integer :: n = 0
   end type
   type(t), parameter :: a(4) = t(2)
   type(t), parameter :: b(4) = reshape(a,[4])
   type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.])
   type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],a)
end

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
  2022-09-27 16:20 ` [Bug fortran/107054] " gscfq@t-online.de
@ 2022-09-27 18:02 ` anlauf at gcc dot gnu.org
  2022-09-27 19:07 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-27 18:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |10.5
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2022-09-27
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P4

--- Comment #2 from anlauf at gcc dot gnu.org ---
Confirmed.

We hit an assert that is fixed by:

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index c0fbd0ed7c2..6ac92cf9db8 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -8458,9 +8458,16 @@ gfc_simplify_unpack (gfc_expr *vector, gfc_expr *mask,
gfc_expr *field)
     {
       if (mask_ctor->expr->value.logical)
        {
-         gcc_assert (vector_ctor);
-         e = gfc_copy_expr (vector_ctor->expr);
-         vector_ctor = gfc_constructor_next (vector_ctor);
+         if (vector_ctor)
+           {
+             e = gfc_copy_expr (vector_ctor->expr);
+             vector_ctor = gfc_constructor_next (vector_ctor);
+           }
+         else
+           {
+             gfc_free_expr (result);
+             return NULL;
+           }
        }
       else if (field->expr_type == EXPR_ARRAY)
        e = gfc_copy_expr (field_ctor->expr);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
  2022-09-27 16:20 ` [Bug fortran/107054] " gscfq@t-online.de
  2022-09-27 18:02 ` anlauf at gcc dot gnu.org
@ 2022-09-27 19:07 ` anlauf at gcc dot gnu.org
  2022-09-27 19:40 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-27 19:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

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 #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-September/058250.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-09-27 19:07 ` anlauf at gcc dot gnu.org
@ 2022-09-27 19:40 ` cvs-commit at gcc dot gnu.org
  2022-09-29 10:44 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-27 19:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

--- Comment #4 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:78bc6497fc61bbdacfb416ee0246a775360d9af6

commit r13-2904-g78bc6497fc61bbdacfb416ee0246a775360d9af6
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 27 20:54:28 2022 +0200

    Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]

    gcc/fortran/ChangeLog:

            PR fortran/107054
            * simplify.cc (gfc_simplify_unpack): Replace assert by condition
            that terminates simplification when there are not enough elements
            in the constructor of argument VECTOR.

    gcc/testsuite/ChangeLog:

            PR fortran/107054
            * gfortran.dg/pr107054.f90: New test.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-09-27 19:40 ` cvs-commit at gcc dot gnu.org
@ 2022-09-29 10:44 ` marxin at gcc dot gnu.org
  2022-09-29 18:39 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-29 10:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Btw. started with r12-4278-g74ccca380cde5e79.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-09-29 10:44 ` marxin at gcc dot gnu.org
@ 2022-09-29 18:39 ` cvs-commit at gcc dot gnu.org
  2022-09-30 20:33 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-29 18:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:2773a90c0f4f323e8ace0593893bc8fcbd2266cf

commit r12-8798-g2773a90c0f4f323e8ace0593893bc8fcbd2266cf
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 27 20:54:28 2022 +0200

    Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]

    gcc/fortran/ChangeLog:

            PR fortran/107054
            * simplify.cc (gfc_simplify_unpack): Replace assert by condition
            that terminates simplification when there are not enough elements
            in the constructor of argument VECTOR.

    gcc/testsuite/ChangeLog:

            PR fortran/107054
            * gfortran.dg/pr107054.f90: New test.

    (cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-09-29 18:39 ` cvs-commit at gcc dot gnu.org
@ 2022-09-30 20:33 ` cvs-commit at gcc dot gnu.org
  2022-09-30 20:34 ` cvs-commit at gcc dot gnu.org
  2022-09-30 20:35 ` anlauf at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-30 20:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

--- Comment #7 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:c4f53f59aaa208f6c7aff0a8b4fb1950b1dc75a0

commit r11-10284-gc4f53f59aaa208f6c7aff0a8b4fb1950b1dc75a0
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 27 20:54:28 2022 +0200

    Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]

    gcc/fortran/ChangeLog:

            PR fortran/107054
            * simplify.c (gfc_simplify_unpack): Replace assert by condition
            that terminates simplification when there are not enough elements
            in the constructor of argument VECTOR.

    gcc/testsuite/ChangeLog:

            PR fortran/107054
            * gfortran.dg/pr107054.f90: New test.

    (cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-09-30 20:33 ` cvs-commit at gcc dot gnu.org
@ 2022-09-30 20:34 ` cvs-commit at gcc dot gnu.org
  2022-09-30 20:35 ` anlauf at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-30 20:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

--- Comment #8 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:b2bd7622721c3a35a9884135e719ae6b0fdc3e2d

commit r10-11013-gb2bd7622721c3a35a9884135e719ae6b0fdc3e2d
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 27 20:54:28 2022 +0200

    Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]

    gcc/fortran/ChangeLog:

            PR fortran/107054
            * simplify.c (gfc_simplify_unpack): Replace assert by condition
            that terminates simplification when there are not enough elements
            in the constructor of argument VECTOR.

    gcc/testsuite/ChangeLog:

            PR fortran/107054
            * gfortran.dg/pr107054.f90: New test.

    (cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/107054] [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461
  2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2022-09-30 20:34 ` cvs-commit at gcc dot gnu.org
@ 2022-09-30 20:35 ` anlauf at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-30 20:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107054

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on all affected branches.  Closing.

Thanks for the report!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-30 20:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 16:19 [Bug fortran/107054] New: [10/11/12/13 Regression] ICE in gfc_simplify_unpack, at fortran/simplify.cc:8461 gscfq@t-online.de
2022-09-27 16:20 ` [Bug fortran/107054] " gscfq@t-online.de
2022-09-27 18:02 ` anlauf at gcc dot gnu.org
2022-09-27 19:07 ` anlauf at gcc dot gnu.org
2022-09-27 19:40 ` cvs-commit at gcc dot gnu.org
2022-09-29 10:44 ` marxin at gcc dot gnu.org
2022-09-29 18:39 ` cvs-commit at gcc dot gnu.org
2022-09-30 20:33 ` cvs-commit at gcc dot gnu.org
2022-09-30 20:34 ` cvs-commit at gcc dot gnu.org
2022-09-30 20:35 ` 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).