Bug 92975 - ICE in convert_nonlocal_reference_op, in tree-nested.c:1065
Summary: ICE in convert_nonlocal_reference_op, in tree-nested.c:1065
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-12-17 18:45 UTC by G. Steinmetz
Modified: 2022-10-04 04:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2019-12-17 18:45:00 UTC
In addition to pr92781, some examples with a procedure pointer 
embedded in a block. ICEs down to at least gfortran-5 :


$ cat z1.f90
program p
   block
      procedure(s), pointer :: g
      g => s
      call g
      call s
   end block
contains
   subroutine s
      print *, 's'
   end
end


$ cat z3.f90
program p
   block
      procedure(s), pointer :: g
      g => s
      print *, g()
      print *, s()
   end block
contains
   function s() result(n)
      n = 1
   end
end


$ gfortran-10-20191215 -c z1.f90
z1.f90:1:0:

    1 | program p
      |
internal compiler error: Segmentation fault
0xb8147f crash_signal
        ../../gcc/toplev.c:328
0xc0cce3 convert_nonlocal_reference_op
        ../../gcc/tree-nested.c:1065
0xde2d35 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ../../gcc/tree.c:11954
0x91e3dd walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        ../../gcc/gimple-walk.c:221
0x91e5f8 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        ../../gcc/gimple-walk.c:596
0x91e7a0 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        ../../gcc/gimple-walk.c:51
0x91e681 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        ../../gcc/gimple-walk.c:605
0x91e7a0 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        ../../gcc/gimple-walk.c:51
0xc09a48 walk_body
        ../../gcc/tree-nested.c:713
0xc0a248 walk_function
        ../../gcc/tree-nested.c:724
0xc0a248 walk_all_functions
        ../../gcc/tree-nested.c:789
0xc0defd lower_nested_functions(tree_node*)
        ../../gcc/tree-nested.c:3528
0x7d47f4 cgraph_node::analyze()
        ../../gcc/cgraphunit.c:675
0x7d7457 analyze_functions
        ../../gcc/cgraphunit.c:1212
0x7d7db2 symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.c:2958
Comment 1 G. Steinmetz 2019-12-17 18:46:00 UTC
Without such a block :


$ cat z2.f90
program p
   procedure(s), pointer :: g
   g => s
   call g
   call s
contains
   subroutine s
      print *, 's'
   end
end


$ cat z4.f90
program p
   procedure(s), pointer :: g
   g => s
   print *, g()
   print *, s()
contains
   function s() result(n)
      n = 1
   end
end


$ gfortran-10-20191215 z2.f90 && ./a.out
 s
 s

$ gfortran-10-20191215 z4.f90 && ./a.out
           1
           1
Comment 2 Thomas Koenig 2019-12-20 12:51:28 UTC
Still fails with current trunk; not fixed with the fix for PR92781.