public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119
@ 2021-12-06 20:26 gscfq@t-online.de
  2021-12-06 21:08 ` [Bug fortran/103591] " anlauf at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gscfq@t-online.de @ 2021-12-06 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103591
           Summary: ICE in gfc_compare_string, at fortran/arith.c:1119
           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: ---

Affects versions down to at least r5 :


$ cat z1.f90
program p
   integer :: n
   select case (n)
   case ('1':2.)
   end select
end


$ gfortran-12-20211205 -c z1.f90
f951: internal compiler error: Segmentation fault
0xd6497f crash_signal
        ../../gcc/toplev.c:322
0x7640cb gfc_compare_string(gfc_expr*, gfc_expr*)
        ../../gcc/fortran/arith.c:1119
0x809f46 resolve_select
        ../../gcc/fortran/resolve.c:8784
0x8138f7 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.c:12165
0x8157b7 resolve_codes
        ../../gcc/fortran/resolve.c:17531
0x81587e gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.c:17566
0x7fdba4 resolve_all_program_units
        ../../gcc/fortran/parse.c:6586
0x7fdba4 gfc_parse_file()
        ../../gcc/fortran/parse.c:6842
0x84afaf gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:216

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
@ 2021-12-06 21:08 ` anlauf at gcc dot gnu.org
  2021-12-06 21:46 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-06 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2021-12-06

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

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
  2021-12-06 21:08 ` [Bug fortran/103591] " anlauf at gcc dot gnu.org
@ 2021-12-06 21:46 ` anlauf at gcc dot gnu.org
  2021-12-06 22:20 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-06 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Untested fix:

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 2bf21434a42..52bc5af7542 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6075,6 +6075,15 @@ match_case_selector (gfc_case **cp)
          m = gfc_match_init_expr (&c->high);
          if (m == MATCH_ERROR)
            goto cleanup;
+         if (m == MATCH_YES
+             && c->high->ts.type != BT_LOGICAL
+             && c->high->ts.type != BT_INTEGER
+             && c->high->ts.type != BT_CHARACTER)
+           {
+             gfc_error ("Expression in CASE selector at %L cannot be %s",
+                        &c->high->where, gfc_typename (c->high));
+             goto cleanup;
+           }
          /* MATCH_NO is fine.  It's OK if nothing is there!  */
        }
     }

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
  2021-12-06 21:08 ` [Bug fortran/103591] " anlauf at gcc dot gnu.org
  2021-12-06 21:46 ` anlauf at gcc dot gnu.org
@ 2021-12-06 22:20 ` anlauf at gcc dot gnu.org
  2021-12-07 17:38 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-06 22:20 UTC (permalink / raw)
  To: gcc-bugs

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

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/2021-December/057132.html

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-12-06 22:20 ` anlauf at gcc dot gnu.org
@ 2021-12-07 17:38 ` cvs-commit at gcc dot gnu.org
  2021-12-07 17:40 ` anlauf at gcc dot gnu.org
  2021-12-08 19:23 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-07 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:f47662204de27f7685699eeef89aa173ccf32d85

commit r12-5825-gf47662204de27f7685699eeef89aa173ccf32d85
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Dec 6 23:15:11 2021 +0100

    Fortran: add check for type of upper bound in case range

    gcc/fortran/ChangeLog:

            PR fortran/103591
            * match.c (match_case_selector): Check type of upper bound in case
            range.

    gcc/testsuite/ChangeLog:

            PR fortran/103591
            * gfortran.dg/select_9.f90: New test.

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-12-07 17:38 ` cvs-commit at gcc dot gnu.org
@ 2021-12-07 17:40 ` anlauf at gcc dot gnu.org
  2021-12-08 19:23 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-12-07 17:40 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed for gcc-12.  Closing.

Thanks for the report!

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

* [Bug fortran/103591] ICE in gfc_compare_string, at fortran/arith.c:1119
  2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-12-07 17:40 ` anlauf at gcc dot gnu.org
@ 2021-12-08 19:23 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-08 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:423e0a98e3d972fb180803665a8c02b017b72d15

commit r11-9366-g423e0a98e3d972fb180803665a8c02b017b72d15
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Dec 6 23:15:11 2021 +0100

    Fortran: add check for type of upper bound in case range

    gcc/fortran/ChangeLog:

            PR fortran/103591
            * match.c (match_case_selector): Check type of upper bound in case
            range.

    gcc/testsuite/ChangeLog:

            PR fortran/103591
            * gfortran.dg/select_9.f90: New test.

    (cherry picked from commit f47662204de27f7685699eeef89aa173ccf32d85)

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

end of thread, other threads:[~2021-12-08 19:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 20:26 [Bug fortran/103591] New: ICE in gfc_compare_string, at fortran/arith.c:1119 gscfq@t-online.de
2021-12-06 21:08 ` [Bug fortran/103591] " anlauf at gcc dot gnu.org
2021-12-06 21:46 ` anlauf at gcc dot gnu.org
2021-12-06 22:20 ` anlauf at gcc dot gnu.org
2021-12-07 17:38 ` cvs-commit at gcc dot gnu.org
2021-12-07 17:40 ` anlauf at gcc dot gnu.org
2021-12-08 19:23 ` cvs-commit 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).