[Bug fortran/91784] New: ICE in gfc_real2complex, at fortran/arith.c:2208

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/91784] New: ICE in gfc_real2complex, at fortran/arith.c:2208

marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91784

            Bug ID: 91784
           Summary: ICE in gfc_real2complex, at fortran/arith.c:2208
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: [hidden email]
  Target Milestone: ---

Follow-up of pr91553, with a negation :


$ cat z1.f90
program p
   complex :: x(1)
   x = (1.0, 2.0) * [real :: -(3.0 + 4.0)]
end


$ cat z2.f90
program p
   complex :: x(1)
   x = (1.0, 2.0) * [real :: -2.0 * (3 + 4)]
end


$ gfortran-10-20190915 -c z1.f90
f951: internal compiler error: Segmentation fault
0xb3e54f crash_signal
        ../../gcc/toplev.c:326
0x5e9721 gfc_real2complex(gfc_expr*, int)
        ../../gcc/fortran/arith.c:2208
0x6abd74 gfc_convert_constant(gfc_expr*, bt, int)
        ../../gcc/fortran/simplify.c:8518
0x62fccb do_simplify
        ../../gcc/fortran/intrinsic.c:4540
0x63ae7a gfc_convert_type_warn(gfc_expr*, gfc_typespec*, int, int)
        ../../gcc/fortran/intrinsic.c:5223
0x5e6da3 eval_intrinsic
        ../../gcc/fortran/arith.c:1563
0x65441c match_add_operand
        ../../gcc/fortran/matchexp.c:392
0x6545cc match_level_2
        ../../gcc/fortran/matchexp.c:480
0x654722 match_level_3
        ../../gcc/fortran/matchexp.c:551
0x654814 match_level_4
        ../../gcc/fortran/matchexp.c:599
0x654814 match_and_operand
        ../../gcc/fortran/matchexp.c:693
0x654a02 match_or_operand
        ../../gcc/fortran/matchexp.c:722
0x654ad2 match_equiv_operand
        ../../gcc/fortran/matchexp.c:765
0x654ba4 match_level_5
        ../../gcc/fortran/matchexp.c:811
0x653f81 gfc_match_expr(gfc_expr**)
        ../../gcc/fortran/matchexp.c:870
0x64bff8 gfc_match(char const*, ...)
        ../../gcc/fortran/match.c:1150
0x64d879 gfc_match_assignment()
        ../../gcc/fortran/match.c:1349
0x66fe50 match_word
        ../../gcc/fortran/parse.c:65
0x66fe50 decode_statement
        ../../gcc/fortran/parse.c:361
0x67194a next_free
        ../../gcc/fortran/parse.c:1251
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/91784] ICE in gfc_real2complex, at fortran/arith.c:2208

marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91784

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2019-09-16
                 CC|                            |kargl at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org
   Target Milestone|---                         |9.3
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
Ugh.  I have a patch that fixes this one, too.
I think, however, that we're missing a simplification
step while matching the array constructor.

(Watch for copy-n-paste tab to spaces corruption)

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c      (revision 275730)
+++ gcc/fortran/simplify.c      (working copy)
@@ -8508,10 +8508,10 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind)
            {
              if (c->expr->expr_type == EXPR_ARRAY)
                tmp = gfc_convert_constant (c->expr, type, kind);
-             else if (c->expr->expr_type == EXPR_OP
-                      && c->expr->value.op.op == INTRINSIC_PARENTHESES)
+             else if (c->expr->expr_type == EXPR_OP)
                {
-                 gfc_simplify_expr (c->expr, 1);
+                 if (!gfc_simplify_expr (c->expr, 1))
+                   return &gfc_bad_expr;
                  tmp = f (c->expr, kind);
                }
              else
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/91784] ICE in gfc_real2complex, at fortran/arith.c:2208

marxin at gcc dot gnu.org
In reply to this post by marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91784

--- Comment #2 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Oct  2 17:17:55 2019
New Revision: 276474

URL: https://gcc.gnu.org/viewcvs?rev=276474&root=gcc&view=rev
Log:
2019-10-02  Steven G. Kargl  <[hidden email]>

        PR fortran/91784
        * simplify.c (gfc_convert_constant): Simplify expression if the
        expres  ion type is EXPR_OP.

2019-10-02  Steven G. Kargl  <[hidden email]>

        PR fortran/91784
        * gfortran.dg/pr91784.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr91784.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug fortran/91784] ICE in gfc_real2complex, at fortran/arith.c:2208

marxin at gcc dot gnu.org
In reply to this post by marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91784

kargl at gcc dot gnu.org changed:

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

--- Comment #3 from kargl at gcc dot gnu.org ---
Patch did not apply cleanly to 9-branch.  Closing as fixed.