public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704
@ 2022-10-11 16:58 gscfq@t-online.de
  2022-10-11 19:41 ` [Bug fortran/107217] " anlauf at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gscfq@t-online.de @ 2022-10-11 16:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107217
           Summary: ICE in gfc_arith_times, at fortran/arith.cc:715/704
           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: ---

Affects versions down to at least r5 :


$ cat z1.f90
program p
   print *, [real :: (['1'])] * 2
end

$ cat z2.f90
program p
   print *, 2 * [real :: (['1'])]
end


$ gfortran-13-20221009 -c z1.f90
f951: internal compiler error: gfc_arith_times(): Bad basic type
0x7f6c49 gfc_report_diagnostic
        ../../gcc/fortran/error.cc:883
0x7f87c7 gfc_internal_error(char const*, ...)
        ../../gcc/fortran/error.cc:1503
0x7c0946 gfc_arith_times
        ../../gcc/fortran/arith.cc:715
0x7beef9 reduce_binary_ac
        ../../gcc/fortran/arith.cc:1317
0x7bef55 reduce_binary_ac
        ../../gcc/fortran/arith.cc:1321
0x7bf1a4 reduce_binary
        ../../gcc/fortran/arith.cc:1476
0x7bf5d2 eval_intrinsic
        ../../gcc/fortran/arith.cc:1654
0x83208c match_add_operand
        ../../gcc/fortran/matchexp.cc:392
0x83223c match_level_2
        ../../gcc/fortran/matchexp.cc:480
0x832392 match_level_3
        ../../gcc/fortran/matchexp.cc:551
0x832484 match_level_4
        ../../gcc/fortran/matchexp.cc:599
0x832484 match_and_operand
        ../../gcc/fortran/matchexp.cc:693
0x832672 match_or_operand
        ../../gcc/fortran/matchexp.cc:722
0x832742 match_equiv_operand
        ../../gcc/fortran/matchexp.cc:765
0x832814 match_level_5
        ../../gcc/fortran/matchexp.cc:811
0x831be1 gfc_match_expr(gfc_expr**)
        ../../gcc/fortran/matchexp.cc:870
0x8192d9 match_io_element
        ../../gcc/fortran/io.cc:3668
0x81bc0a match_io_list
        ../../gcc/fortran/io.cc:3716
0x81c00e match_io
        ../../gcc/fortran/io.cc:4394
0x81fb0a gfc_match_print()
        ../../gcc/fortran/io.cc:4450

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

* [Bug fortran/107217] ICE in gfc_arith_times, at fortran/arith.cc:715/704
  2022-10-11 16:58 [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704 gscfq@t-online.de
@ 2022-10-11 19:41 ` anlauf at gcc dot gnu.org
  2022-10-11 20:23 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-11 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-10-11
                 CC|                            |anlauf at gcc dot gnu.org

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

Testing the following patch:

diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index 9e079e42995..c224cd30a54 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -692,6 +692,9 @@ gfc_arith_times (gfc_expr *op1, gfc_expr *op2, gfc_expr
**resultp)
   gfc_expr *result;
   arith rc;

+  if (op1->ts.type != op2->ts.type)
+    return ARITH_INVALID_TYPE;
+
   result = gfc_get_constant_expr (op1->ts.type, op1->ts.kind, &op1->where);

   switch (op1->ts.type)
@@ -712,7 +715,8 @@ gfc_arith_times (gfc_expr *op1, gfc_expr *op2, gfc_expr
**resultp)
       break;

     default:
-      gfc_internal_error ("gfc_arith_times(): Bad basic type");
+      gfc_free_expr (result);
+      return ARITH_INVALID_TYPE;
     }

   rc = gfc_range_check (result);

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

* [Bug fortran/107217] ICE in gfc_arith_times, at fortran/arith.cc:715/704
  2022-10-11 16:58 [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704 gscfq@t-online.de
  2022-10-11 19:41 ` [Bug fortran/107217] " anlauf at gcc dot gnu.org
@ 2022-10-11 20:23 ` anlauf at gcc dot gnu.org
  2022-10-12 17:48 ` cvs-commit at gcc dot gnu.org
  2022-10-12 18:20 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-11 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-October/058328.html

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

* [Bug fortran/107217] ICE in gfc_arith_times, at fortran/arith.cc:715/704
  2022-10-11 16:58 [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704 gscfq@t-online.de
  2022-10-11 19:41 ` [Bug fortran/107217] " anlauf at gcc dot gnu.org
  2022-10-11 20:23 ` anlauf at gcc dot gnu.org
@ 2022-10-12 17:48 ` cvs-commit at gcc dot gnu.org
  2022-10-12 18:20 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-12 17:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:7858368c3f3875f6bf634119e5731dc3c808a7c3

commit r13-3260-g7858368c3f3875f6bf634119e5731dc3c808a7c3
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Oct 11 22:08:48 2022 +0200

    Fortran: check types of operands of arithmetic binary operations [PR107217]

    gcc/fortran/ChangeLog:

            PR fortran/107217
            * arith.cc (gfc_arith_plus): Compare consistency of types of
operands.
            (gfc_arith_minus): Likewise.
            (gfc_arith_times): Likewise.
            (gfc_arith_divide): Likewise.
            (arith_power): Check that both operands are of numeric type.

    gcc/testsuite/ChangeLog:

            PR fortran/107217
            * gfortran.dg/pr107217.f90: New test.

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

* [Bug fortran/107217] ICE in gfc_arith_times, at fortran/arith.cc:715/704
  2022-10-11 16:58 [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-10-12 17:48 ` cvs-commit at gcc dot gnu.org
@ 2022-10-12 18:20 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-12 18:20 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED

--- Comment #4 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2022-10-12 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 16:58 [Bug fortran/107217] New: ICE in gfc_arith_times, at fortran/arith.cc:715/704 gscfq@t-online.de
2022-10-11 19:41 ` [Bug fortran/107217] " anlauf at gcc dot gnu.org
2022-10-11 20:23 ` anlauf at gcc dot gnu.org
2022-10-12 17:48 ` cvs-commit at gcc dot gnu.org
2022-10-12 18:20 ` 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).