Bug 84539 - ICE and segfault with assignment to CLASS(*) array
Summary: ICE and segfault with assignment to CLASS(*) array
Status: RESOLVED DUPLICATE of bug 87625
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-24 07:08 UTC by Neil Carlson
Modified: 2018-10-20 17:05 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Carlson 2018-02-24 07:08:09 UTC
Here are some issues with array assignment to an allocatable CLASS(*) array using the current 8.0 trunk.

class(*), allocatable :: x(:)
x = [4,2]
select type (x)
type is (integer)
  if (any(x /= [4,2])) stop 1
end select
end

$ gfortran -g -fbacktrace gfortran-20180223a.f90 
gfortran-20180223a.f90:1:0:

 class(*), allocatable :: x(:)
 
Error: conversion of register to a different size
VIEW_CONVERT_EXPR<void *>(_1);

_12 = VIEW_CONVERT_EXPR<void *>(_1);
gfortran-20180223a.f90:1:0: internal compiler error: verify_gimple failed
0xd2b9bd verify_gimple_in_seq(gimple*)
	../../gcc/tree-cfg.c:5247
0xaa7495 gimplify_body(tree_node*, bool)
	../../gcc/gimplify.c:12710
0xaa7684 gimplify_function_tree(tree_node*)
	../../gcc/gimplify.c:12800
0x925d17 cgraph_node::analyze()
	../../gcc/cgraphunit.c:670
0x9286b3 analyze_functions
	../../gcc/cgraphunit.c:1131
0x9294a2 symbol_table::finalize_compilation_unit()
	../../gcc/cgraphunit.c:2691
Please submit a full bug report,
Comment 1 Neil Carlson 2018-02-24 07:12:21 UTC
And same example but using character data. This compiles but gives a segfault when run at the assignment statement.

class(*), allocatable :: x(:)
x = ['foo','bar']
select type (x)
type is (character(*))
  if (any(x /= ['foo','bar'])) stop 1
end select
end


$ gfortran -g gfortran-20180223b.f90 
$ ./a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f40a5b0894f in ???
#1  0x400853 in MAIN__
	at gfortran-20180223b.f90:2
#2  0x4009fd in main
	at gfortran-20180223b.f90:7
Segmentation fault (core dumped)
Comment 2 Dominique d'Humieres 2018-02-24 19:56:07 UTC
Confirmed, present since at least r245582.
Comment 3 Dominique d'Humieres 2018-02-24 20:00:06 UTC
> Confirmed, present since at least r245582.

Forgot to say that the ICE requires a compiler configured with --enable-checking=yes.
Comment 4 Neil Carlson 2018-08-17 00:10:53 UTC
Update with 8.2.0

The ICE is gone, but a run time segfault remains:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f82986c06df in ???
#1  0x400754 in MAIN__
	at gfortran-20180223a.f90:2
#2  0x400979 in main
	at gfortran-20180223a.f90:7
Segmentation fault (core dumped)
Comment 5 Dominique d'Humieres 2018-10-20 17:05:10 UTC
This seems fixed after revision r265283. Likely a duplicate of pr87625.

*** This bug has been marked as a duplicate of bug 87625 ***