Bug 71807 - [5/6/7 Regression] Internal compiler error with NULL() reference in structure constructor
Summary: [5/6/7 Regression] Internal compiler error with NULL() reference in structure...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 5.5
Assignee: vehre
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-07-08 00:42 UTC by Ian Harvey
Modified: 2016-08-04 13:06 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Harvey 2016-07-08 00:42:14 UTC
The following snippet, when compiled with gfortran recent trunk (r238061) or 6.1.1 results in an internal compiler error.

~~

MODULE fold_convert_loc_ice
  IMPLICIT NONE
  PRIVATE
  
  TYPE, PUBLIC :: ta
    PRIVATE
    INTEGER :: a_comp
  END TYPE ta
  
  TYPE, PUBLIC :: tb
    TYPE(ta), ALLOCATABLE :: b_comp
  END TYPE tb
CONTAINS
  SUBROUTINE proc
    TYPE(tb) :: b
    
    b = tb(null())
  END SUBROUTINE proc
END MODULE fold_convert_loc_ice

~~

$ gfortran -c -v fold_convert_loc_ice.f90
Using built-in specs.
COLLECT_GCC=gfortran
Target: x86_64-pc-linux-gnu
Configured with: .././src/configure --prefix=/home/MEGMS2/ian/usr/gcc-7.0.0 --enable-languages=c,c++,fortran --enable-libgomp --enable-checking=release
Thread model: posix
gcc version 7.0.0 20160706 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-c' '-v' '-mtune=generic' '-march=x86-64'
 /home/MEGMS2/ian/usr/gcc-7.0.0/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/f951 fold_convert_loc_ice.f90 -quiet -dumpbase fold_convert_loc_ice.f90 -mtune=generic -march=x86-64 -auxbase fold_convert_loc_ice -version -fintrinsic-modules-path /home/MEGMS2/ian/usr/gcc-7.0.0/lib/gcc/x86_64-pc-linux-gnu/7.0.0/finclude -o /tmp/cc3kuTzv.s
GNU Fortran (GCC) version 7.0.0 20160706 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 7.0.0 20160704 (experimental), GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 7.0.0 20160706 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 7.0.0 20160704 (experimental), GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
fold_convert_loc_ice.f90:17:0:

     b = tb(null())

internal compiler error: in fold_convert_loc, at fold-const.c:2371
0x833153 fold_convert_loc(unsigned int, tree_node*, tree_node*)
        ../.././src/gcc/fold-const.c:2371
0x6b6e27 gfc_trans_subcomponent_assign
        ../.././src/gcc/fortran/trans-expr.c:7250
0x6b6653 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool)
        ../.././src/gcc/fortran/trans-expr.c:7391
0x6b7dbf gfc_conv_structure(gfc_se*, gfc_expr*, int)
        ../.././src/gcc/fortran/trans-expr.c:7420
0x6b8e62 gfc_trans_assignment_1
        ../.././src/gcc/fortran/trans-expr.c:9317
0x682275 trans_code
        ../.././src/gcc/fortran/trans.c:1678
0x6a6019 gfc_generate_function_code(gfc_namespace*)
        ../.././src/gcc/fortran/trans-decl.c:6202
0x685a39 gfc_generate_module_code(gfc_namespace*)
        ../.././src/gcc/fortran/trans.c:2056
0x63d2eb translate_all_program_units
        ../.././src/gcc/fortran/parse.c:5873
0x63d2eb gfc_parse_file()
        ../.././src/gcc/fortran/parse.c:6092
0x67ec62 gfc_be_parse_file
        ../.././src/gcc/fortran/f95-lang.c:198
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Martin Liška 2016-07-08 07:34:49 UTC
Confirmed, it's a regression since GCC 5.
Comment 2 Jakub Jelinek 2016-07-08 07:43:57 UTC
Started with r219801.
Comment 3 vehre 2016-07-14 16:17:50 UTC
Patch available at

https://gcc.gnu.org/ml/fortran/2016-07/msg00065.html

Waiting for review.
Comment 4 vehre 2016-07-15 09:29:18 UTC
Author: vehre
Date: Fri Jul 15 09:28:47 2016
New Revision: 238368

URL: https://gcc.gnu.org/viewcvs?rev=238368&root=gcc&view=rev
Log:
gcc/fortran/ChangeLog:

2016-07-15  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/71807
	* trans-expr.c (gfc_trans_subcomponent_assign): Special casing
	when allocatable component is set to null() in initializer.

gcc/testsuite/ChangeLog:

2016-07-15  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/71807
	* gfortran.dg/null_9.f90: New test.



Added:
    trunk/gcc/testsuite/gfortran.dg/null_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 vehre 2016-07-15 11:38:02 UTC
Waiting one week for regression reports before applying to gcc-*-branches.
Comment 6 vehre 2016-07-22 15:15:25 UTC
Author: vehre
Date: Fri Jul 22 15:14:53 2016
New Revision: 238649

URL: https://gcc.gnu.org/viewcvs?rev=238649&root=gcc&view=rev
Log:
gcc/fortran/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	Backported from trunk:
	PR fortran/71807
	* trans-expr.c (gfc_trans_subcomponent_assign): Special casing
	when allocatable component is set to null() in initializer.

gcc/testsuite/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	Backported from trunk:
	PR fortran/71807
	* gfortran.dg/null_9.f90: New test.



Added:
    branches/gcc-6-branch/gcc/testsuite/gfortran.dg/null_9.f90
Modified:
    branches/gcc-6-branch/gcc/fortran/ChangeLog
    branches/gcc-6-branch/gcc/fortran/trans-expr.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 7 vehre 2016-07-22 15:21:42 UTC
Author: vehre
Date: Fri Jul 22 15:21:10 2016
New Revision: 238650

URL: https://gcc.gnu.org/viewcvs?rev=238650&root=gcc&view=rev
Log:
gcc/fortran/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	Backported from trunk:
	PR fortran/71807
	* trans-expr.c (gfc_trans_subcomponent_assign): Special casing
	when allocatable component is set to null() in initializer.

gcc/testsuite/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	Backported from trunk:
	PR fortran/71807
	* gfortran.dg/null_9.f90: New test.



Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/null_9.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/trans-expr.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 8 vehre 2016-07-22 15:27:57 UTC
Waiting one week for regressions before closing.
Comment 9 Dominique d'Humieres 2016-08-04 13:06:37 UTC
> Waiting one week for regressions before closing.

So closing.