public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar
@ 2015-09-17 18:06 gerhard.steinmetz.fortran@t-online.de
  2015-09-17 18:07 ` [Bug fortran/67615] " gerhard.steinmetz.fortran@t-online.de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-09-17 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67615
           Summary: ICE on using arithmetic if with array instead of
                    scalar
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gerhard.steinmetz.fortran@t-online.de
  Target Milestone: ---

An arithmetic if with an array instead of a numeric scalar :

   program p
      integer :: z(1) = [1]
      if ( z ) 1, 2, 3
    1 stop 1
    2 stop 2
    3 stop 3
   end

or this variation :

   program p
      integer :: z(2) = [1, 2]
      if ( z ) 1, 2, 3
    1 stop 1
    2 stop 2
    3 stop 3
   end


yields :
internal compiler error: Segmentation fault


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
@ 2015-09-17 18:07 ` gerhard.steinmetz.fortran@t-online.de
  2015-09-17 22:59 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-09-17 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
With an array constructor :


$ cat z6.f90
program p
   if ( [1] ) 1, 2, 3
   if ( [1, -1] ) 1, 2, 3
   if ( [real :: 1, -1] ) 1, 2, 3
 1 stop 1
 2 stop 2
 3 stop 3
end


$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize z6.f90
z6.f90:2:0:

    if ( [1] ) 1, 2, 3
 1
internal compiler error: in gfc_conv_array_constructor_expr, at
fortran/trans-expr.c:6326


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
  2015-09-17 18:07 ` [Bug fortran/67615] " gerhard.steinmetz.fortran@t-online.de
@ 2015-09-17 22:59 ` dominiq at lps dot ens.fr
  2015-09-18 19:40 ` kargl at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-17 22:59 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-09-17
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from 4.8 up to trunk (6.0).

Backtrace

* thread #1: tid = 0x97e3343, 0x00000001000dc6ee
f951`::gfc_conv_scalarized_array_ref(se=0x00007fff5fbfef40,
ar=0x0000000144b01728) + 30 at trans-array.c:3129, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001000dc6ee
f951`::gfc_conv_scalarized_array_ref(se=0x00007fff5fbfef40,
ar=0x0000000144b01728) + 30 at trans-array.c:3129
   3126   int n;
   3127 
   3128   ss = se->ss;
-> 3129   expr = ss->info->expr;
   3130   info = &ss->info->data.array;
   3131   if (ar)
   3132     n = se->loop->order[0];
(lldb) bt
* thread #1: tid = 0x97e3343, 0x00000001000dc6ee
f951`::gfc_conv_scalarized_array_ref(se=0x00007fff5fbfef40,
ar=0x0000000144b01728) + 30 at trans-array.c:3129, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001000dc6ee
f951`::gfc_conv_scalarized_array_ref(se=0x00007fff5fbfef40,
ar=0x0000000144b01728) + 30 at trans-array.c:3129
    frame #1: 0x00000001000dd26a f951`gfc_conv_array_ref(se=0x00007fff5fbfef40,
ar=0x0000000144b01728, expr=<unavailable>, where=0x0000000144b016b0) + 154 at
trans-array.c:3281
    frame #2: 0x0000000100109f5e
f951`::gfc_conv_variable(se=0x00007fff5fbfef40, expr=0x0000000144b01660) + 414
at trans-expr.c:2567
    frame #3: 0x0000000100108594 f951`gfc_conv_expr_val(se=0x00007fff5fbfef40,
expr=<unavailable>) + 20 at trans-expr.c:7535
    frame #4: 0x000000010013b6a4
f951`gfc_trans_arithmetic_if(code=0x0000000144b019a0) + 52 at trans-stmt.c:1183
    frame #5: 0x00000001000d4c48 f951`::trans_code(code=0x0000000144b019a0,
cond=0x0000000000000000) + 1176 at trans.c:1744
    frame #6: 0x00000001000fa015
f951`gfc_generate_function_code(ns=<unavailable>) + 1061 at trans-decl.c:5900
    frame #7: 0x000000010008bedc f951`gfc_parse_file() + 1628 at parse.c:5526
    frame #8: 0x00000001000d1ad6 f951`::gfc_be_parse_file() + 54 at
f95-lang.c:209
    frame #9: 0x000000010091d67a f951`::compile_file() + 58 at toplev.c:545
    frame #10: 0x0000000100cf817c f951`toplev::main(int, char**) + 1151 at
toplev.c:2035
    frame #11: 0x0000000100cf7cfd f951`toplev::main(this=<unavailable>, argc=2,
argv=0x00007fff5fbff350) + 717
    frame #12: 0x0000000100cf9be9 f951`main(argc=2, argv=0x00007fff5fbff350) +
41 at main.c:39


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
  2015-09-17 18:07 ` [Bug fortran/67615] " gerhard.steinmetz.fortran@t-online.de
  2015-09-17 22:59 ` dominiq at lps dot ens.fr
@ 2015-09-18 19:40 ` kargl at gcc dot gnu.org
  2015-09-21 18:09 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-18 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #3)
> This patch to resolve.c catches the problem.  Watch for
> cut-n-paste corruption of tabs.
> 
> @@ -10377,12 +10381,11 @@ gfc_resolve_code (gfc_code *code, gfc_na
>           }
>  
>         case EXEC_ARITHMETIC_IF:
> -         if (t
> -             && code->expr1->ts.type != BT_INTEGER
> -             && code->expr1->ts.type != BT_REAL)
> -           gfc_error ("Arithmetic IF statement at %L requires a numeric "
> -                      "expression", &code->expr1->where);
>  
> +         if (t && (code->expr1->rank > 0 || !gfc_numeric_ts
> (&code->expr1->ts)))
> +           gfc_error ("Arithmetic IF statement at %L requires a scalar "
> +                      "numeric expression", &code->expr1->where);
> +         
>           resolve_branch (code->label1, code);
>           resolve_branch (code->label2, code);
>           resolve_branch (code->label3, code);
> 
> Whoops.  Needs for for BT_COMPLEX.

Better patch

@@ -10377,12 +10381,13 @@ gfc_resolve_code (gfc_code *code, gfc_na
          }

        case EXEC_ARITHMETIC_IF:
-         if (t
-             && code->expr1->ts.type != BT_INTEGER
-             && code->expr1->ts.type != BT_REAL)
-           gfc_error ("Arithmetic IF statement at %L requires a numeric "
-                      "expression", &code->expr1->where);

+         if (t && (code->expr1->rank > 0
+                   || !(code->expr1->ts.type == BT_REAL
+                        || code->expr1->ts.type == BT_INTEGER)))
+           gfc_error ("Arithmetic IF statement at %L requires a scalar "
+                      "REAL or INTEGER expression", &code->expr1->where);
+         
          resolve_branch (code->label1, code);
          resolve_branch (code->label2, code);
          resolve_branch (code->label3, code);


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
                   ` (2 preceding siblings ...)
  2015-09-18 19:40 ` kargl at gcc dot gnu.org
@ 2015-09-21 18:09 ` kargl at gcc dot gnu.org
  2015-09-21 18:25 ` kargl at gcc dot gnu.org
  2015-09-21 18:27 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-21 18:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Mon Sep 21 18:09:13 2015
New Revision: 227981

URL: https://gcc.gnu.org/viewcvs?rev=227981&root=gcc&view=rev
Log:
2015-09-21  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67615
        * resolve.c (gfc_resolve_code): Check for scalar expression in 
        arithmetic-if.


2015-09-21  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67615
        * gfortran.dg/pr67615.f90: new test.


Added:
    trunk/gcc/testsuite/gfortran.dg/pr67615.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
                   ` (3 preceding siblings ...)
  2015-09-21 18:09 ` kargl at gcc dot gnu.org
@ 2015-09-21 18:25 ` kargl at gcc dot gnu.org
  2015-09-21 18:27 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-21 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Mon Sep 21 18:24:52 2015
New Revision: 227982

URL: https://gcc.gnu.org/viewcvs?rev=227982&root=gcc&view=rev
Log:
2015-09-21  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67615
        * resolve.c (gfc_resolve_code): Check for scalar expression in 
        arithmetic-if.

2015-09-21  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67615
        * gfortran.dg/pr67615.f90: new test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr67615.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/resolve.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/67615] ICE on using arithmetic if with array instead of scalar
  2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
                   ` (4 preceding siblings ...)
  2015-09-21 18:25 ` kargl at gcc dot gnu.org
@ 2015-09-21 18:27 ` kargl at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-21 18:27 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #7 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.  Thanks for bug report.


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

end of thread, other threads:[~2015-09-21 18:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 18:06 [Bug fortran/67615] New: ICE on using arithmetic if with array instead of scalar gerhard.steinmetz.fortran@t-online.de
2015-09-17 18:07 ` [Bug fortran/67615] " gerhard.steinmetz.fortran@t-online.de
2015-09-17 22:59 ` dominiq at lps dot ens.fr
2015-09-18 19:40 ` kargl at gcc dot gnu.org
2015-09-21 18:09 ` kargl at gcc dot gnu.org
2015-09-21 18:25 ` kargl at gcc dot gnu.org
2015-09-21 18:27 ` kargl 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).