public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed
@ 2022-09-14 18:52 gscfq@t-online.de
  2022-09-14 18:52 ` [Bug fortran/106945] " gscfq@t-online.de
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: gscfq@t-online.de @ 2022-09-14 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106945
           Summary: [10/11/12/13 Regression] ICE: 'verify_gimple' failed
           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: ---

Started with r7, using option -fcoarray=single or -fcoarray=lib :
(gcc configured with --enable-checking=yes)


$ cat z1.f90
module m
   type t
      class(*), allocatable :: a[:]
   end type
end


$ gfortran-13-20220911 -c z1.f90 -ftrapv -fcheck=all -fcoarray=lib
z1.f90:5:3:

    5 | end
      |   ^
Error: mismatching comparison operand types
integer(kind=8)
unsigned long
if (_10 != 1) goto <D.4519>; else goto <D.4520>;
z1.f90:5:3: internal compiler error: 'verify_gimple' failed
0xf8e34d verify_gimple_in_seq(gimple*)
        ../../gcc/tree-cfg.cc:5221
0xc07671 gimplify_body(tree_node*, bool)
        ../../gcc/gimplify.cc:16605
0xc07915 gimplify_function_tree(tree_node*)
        ../../gcc/gimplify.cc:16721
0xa20787 cgraph_node::analyze()
        ../../gcc/cgraphunit.cc:676
0xa23a66 analyze_functions
        ../../gcc/cgraphunit.cc:1240
0xa24c0d symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.cc:2500

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
@ 2022-09-14 18:52 ` gscfq@t-online.de
  2022-09-14 19:58 ` marxin at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gscfq@t-online.de @ 2022-09-14 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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


No ICE with "program" instead of "module" :

$ cat z2.f90
program p
   type t
      class(*), allocatable :: a[:]
   end type
end

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
  2022-09-14 18:52 ` [Bug fortran/106945] " gscfq@t-online.de
@ 2022-09-14 19:58 ` marxin at gcc dot gnu.org
  2022-09-15  7:18 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-14 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-09-14
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |pault at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r8-4344-gaea5e9327a49bc73.

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
  2022-09-14 18:52 ` [Bug fortran/106945] " gscfq@t-online.de
  2022-09-14 19:58 ` marxin at gcc dot gnu.org
@ 2022-09-15  7:18 ` rguenth at gcc dot gnu.org
  2022-09-23 19:56 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-15  7:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.5
           Priority|P3                          |P4

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-09-15  7:18 ` rguenth at gcc dot gnu.org
@ 2022-09-23 19:56 ` anlauf at gcc dot gnu.org
  2023-03-10 21:21 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-23 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from anlauf at gcc dot gnu.org ---
It is -fcheck=bounds that is required to trigger the failure.

Replacing -ftrapv by -fsanitize=undefined produces the same error.

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-09-23 19:56 ` anlauf at gcc dot gnu.org
@ 2023-03-10 21:21 ` anlauf at gcc dot gnu.org
  2023-03-11 14:35 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-03-10 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
As there is no ICE with -fcheck=bounds -fwrapv but with -fcheck=bounds -ftrapv,
there might be a wrapping issue with the bounds checking code.

Difference of the dump-trees:

--- pr106945-z1.f90.005t.original.wrapv 2023-03-10 22:15:44.992525716 +0100
+++ pr106945-z1.f90.005t.original.trapv 2023-03-10 22:15:24.892582362 +0100
@@ -268,7 +268,7 @@
             D.4395 = (unsigned long) src->a._vptr->_size;
             D.4396 = (unsigned long) src->a._len;
             D.4397 = D.4396 != 0 ? D.4395 * D.4396 : D.4395;
-            if (src->a._data.dim[0].ubound != src->a._data.dim[0].lbound)
+            if ((src->a._data.dim[0].ubound - src->a._data.dim[0].lbound) + 1
!= 1)
               {
                 _gfortran_runtime_error_at (&"At line 9 of file
pr106945-z1.f90"[1]{lb: 1 sz: 1}, &"Array bound mismatch for dimension 1 of
array \'<<unknown>>\' (%ld/%ld)"[1]{lb: 1 sz: 1}, 1, MAX_EXPR
<(src->a._data.dim[0].ubound - src->a._data.dim[0].lbound) + 1, 0>);
               }


I am having difficulties to understand the code generated for -ftrapv.

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-03-10 21:21 ` anlauf at gcc dot gnu.org
@ 2023-03-11 14:35 ` anlauf at gcc dot gnu.org
  2023-03-11 14:52 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-03-11 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

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 ---
The issue appears to be a missing conversion:

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 045c8b00b90..dcd39f46776 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1531,6 +1531,7 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems,
bool unlimited)
            name = (const char *)(DECL_NAME (to)->identifier.id.str);

          from_len = gfc_conv_descriptor_size (from_data, 1);
+         from_len = fold_convert (TREE_TYPE (orig_nelems), from_len);
          tmp = fold_build2_loc (input_location, NE_EXPR,
                                  logical_type_node, from_len, orig_nelems);
          msg = xasprintf ("Array bound mismatch for dimension %d "

While orig_nelems may come in as size_type_node (i.e. unsigned) from two
callsites, gfc_conv_descriptor_size returns gfc_array_index_type (signed).
As the actual size cannot be negative, it should be safe to convert it to
the type of orig_nelems.

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-03-11 14:35 ` anlauf at gcc dot gnu.org
@ 2023-03-11 14:52 ` cvs-commit at gcc dot gnu.org
  2023-03-15 20:46 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-11 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:2cf5f485e0351bb1faf46196a99e524688f3966e

commit r13-6605-g2cf5f485e0351bb1faf46196a99e524688f3966e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Mar 11 15:37:37 2023 +0100

    Fortran: fix bounds check for copying of class expressions [PR106945]

    In the bounds check for copying of class expressions, the number of
elements
    determined from a descriptor, returned as type gfc_array_index_type (i.e. a
    signed type), should be converted to the type of the passed element count,
    which is of type size_type_node (i.e. unsigned), for use in comparisons.

    gcc/fortran/ChangeLog:

            PR fortran/106945
            * trans-expr.cc (gfc_copy_class_to_class): Convert element counts
in
            bounds check to common type for comparison.

    gcc/testsuite/ChangeLog:

            PR fortran/106945
            * gfortran.dg/pr106945.f90: New test.

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-03-11 14:52 ` cvs-commit at gcc dot gnu.org
@ 2023-03-15 20:46 ` cvs-commit at gcc dot gnu.org
  2023-03-17 20:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-15 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 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:82ca86233da61e868a91b6132191148230d56ab0

commit r12-9266-g82ca86233da61e868a91b6132191148230d56ab0
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Mar 11 15:37:37 2023 +0100

    Fortran: fix bounds check for copying of class expressions [PR106945]

    In the bounds check for copying of class expressions, the number of
elements
    determined from a descriptor, returned as type gfc_array_index_type (i.e. a
    signed type), should be converted to the type of the passed element count,
    which is of type size_type_node (i.e. unsigned), for use in comparisons.

    gcc/fortran/ChangeLog:

            PR fortran/106945
            * trans-expr.cc (gfc_copy_class_to_class): Convert element counts
in
            bounds check to common type for comparison.

    gcc/testsuite/ChangeLog:

            PR fortran/106945
            * gfortran.dg/pr106945.f90: New test.

    (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2023-03-15 20:46 ` cvs-commit at gcc dot gnu.org
@ 2023-03-17 20:40 ` cvs-commit at gcc dot gnu.org
  2023-03-17 20:41 ` cvs-commit at gcc dot gnu.org
  2023-03-17 20:42 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-17 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r11-10584-gf68f0e69d988ca999c09953811f3cc722f114677
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Mar 11 15:37:37 2023 +0100

    Fortran: fix bounds check for copying of class expressions [PR106945]

    In the bounds check for copying of class expressions, the number of
elements
    determined from a descriptor, returned as type gfc_array_index_type (i.e. a
    signed type), should be converted to the type of the passed element count,
    which is of type size_type_node (i.e. unsigned), for use in comparisons.

    gcc/fortran/ChangeLog:

            PR fortran/106945
            * trans-expr.c (gfc_copy_class_to_class): Convert element counts in
            bounds check to common type for comparison.

    gcc/testsuite/ChangeLog:

            PR fortran/106945
            * gfortran.dg/pr106945.f90: New test.

    (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2023-03-17 20:40 ` cvs-commit at gcc dot gnu.org
@ 2023-03-17 20:41 ` cvs-commit at gcc dot gnu.org
  2023-03-17 20:42 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-17 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:3cca6b5fa51fd271644082761de85e89fd56d69c

commit r10-11256-g3cca6b5fa51fd271644082761de85e89fd56d69c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Mar 11 15:37:37 2023 +0100

    Fortran: fix bounds check for copying of class expressions [PR106945]

    In the bounds check for copying of class expressions, the number of
elements
    determined from a descriptor, returned as type gfc_array_index_type (i.e. a
    signed type), should be converted to the type of the passed element count,
    which is of type size_type_node (i.e. unsigned), for use in comparisons.

    gcc/fortran/ChangeLog:

            PR fortran/106945
            * trans-expr.c (gfc_copy_class_to_class): Convert element counts in
            bounds check to common type for comparison.

    gcc/testsuite/ChangeLog:

            PR fortran/106945
            * gfortran.dg/pr106945.f90: New test.

    (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)

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

* [Bug fortran/106945] [10/11/12/13 Regression] ICE: 'verify_gimple' failed
  2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
                   ` (9 preceding siblings ...)
  2023-03-17 20:41 ` cvs-commit at gcc dot gnu.org
@ 2023-03-17 20:42 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-03-17 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

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

Thanks for the report!

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

end of thread, other threads:[~2023-03-17 20:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 18:52 [Bug fortran/106945] New: [10/11/12/13 Regression] ICE: 'verify_gimple' failed gscfq@t-online.de
2022-09-14 18:52 ` [Bug fortran/106945] " gscfq@t-online.de
2022-09-14 19:58 ` marxin at gcc dot gnu.org
2022-09-15  7:18 ` rguenth at gcc dot gnu.org
2022-09-23 19:56 ` anlauf at gcc dot gnu.org
2023-03-10 21:21 ` anlauf at gcc dot gnu.org
2023-03-11 14:35 ` anlauf at gcc dot gnu.org
2023-03-11 14:52 ` cvs-commit at gcc dot gnu.org
2023-03-15 20:46 ` cvs-commit at gcc dot gnu.org
2023-03-17 20:40 ` cvs-commit at gcc dot gnu.org
2023-03-17 20:41 ` cvs-commit at gcc dot gnu.org
2023-03-17 20:42 ` 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).