Bug 86111 - ICE in gfc_arith_concat, at fortran/arith.c:985
Summary: ICE in gfc_arith_concat, at fortran/arith.c:985
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-11 19:25 UTC by G. Steinmetz
Modified: 2018-10-06 22:42 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-06-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2018-06-11 19:25:59 UTC
With invalid code, down to at least gfortran 4.8 :


$ cat z1.f90
program p
   character(2) :: c = 'a' // [character :: [1]]
end

$ cat z2.f90
program p
   real :: c = 'a' // [character :: [1]]
end

$ cat z3.f90
program p
   character(2) :: c = 'a' // [character :: 1.0]
end

# ...


$ gfortran-9-20180610 -c z1.f90
f951: internal compiler error: in gfc_arith_concat, at fortran/arith.c:985
0x629922 gfc_arith_concat
        ../../gcc/fortran/arith.c:985
0x6294b8 reduce_binary_ca
        ../../gcc/fortran/arith.c:1333
0x629482 reduce_binary_ca
        ../../gcc/fortran/arith.c:1335
0x6296c4 reduce_binary
        ../../gcc/fortran/arith.c:1418
0x629ffb eval_intrinsic
        ../../gcc/fortran/arith.c:1596
0x62a25e eval_intrinsic_f3
        ../../gcc/fortran/arith.c:1733
0x69204a match_level_3
        ../../gcc/fortran/matchexp.c:571
0x692134 match_level_4
        ../../gcc/fortran/matchexp.c:599
0x692134 match_and_operand
        ../../gcc/fortran/matchexp.c:693
0x6922f2 match_or_operand
        ../../gcc/fortran/matchexp.c:722
0x6923e2 match_equiv_operand
        ../../gcc/fortran/matchexp.c:765
0x6924d2 match_level_5
        ../../gcc/fortran/matchexp.c:811
0x691841 gfc_match_expr(gfc_expr**)
        ../../gcc/fortran/matchexp.c:870
0x662912 gfc_match_init_expr(gfc_expr**)
        ../../gcc/fortran/expr.c:2807
0x6504e9 variable_decl
        ../../gcc/fortran/decl.c:2681
0x6504e9 gfc_match_data_decl()
        ../../gcc/fortran/decl.c:5893
0x6ab509 match_word_omp_simd
        ../../gcc/fortran/parse.c:93
0x6aebfe match_word
        ../../gcc/fortran/parse.c:376
0x6aebfe decode_statement
        ../../gcc/fortran/parse.c:376
0x6b0b24 next_free
        ../../gcc/fortran/parse.c:1230
Comment 1 kargls 2018-06-11 20:19:09 UTC
This can be fixed in arith.c by inspecting the types of the operands, or in array.c by walking array constructors and inspecting compatibility between a type-spec and constructor elements.
Comment 2 Thomas Koenig 2018-10-06 18:20:46 UTC
Author: tkoenig
Date: Sat Oct  6 18:20:14 2018
New Revision: 264900

URL: https://gcc.gnu.org/viewcvs?rev=264900&root=gcc&view=rev
Log:
2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/86111
	* gfortran.h (enum arith): Add ARITH_WRONGCONCAT.
	* arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT.
	(gfc_arith_concat):  If the types of op1 and op2 are not
	character of if their kinds do not match, issue ARITH_WRONGCONCAT.

2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/86111
	* gfortran.dg/array_constructor_type_23.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/array_constructor_type_23.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/arith.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/testsuite/ChangeLog
Comment 3 Thomas Koenig 2018-10-06 22:41:38 UTC
Author: tkoenig
Date: Sat Oct  6 22:41:06 2018
New Revision: 264902

URL: https://gcc.gnu.org/viewcvs?rev=264902&root=gcc&view=rev
Log:
2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/86111
	Backport from trunk
        * gfortran.h (enum arith): Add ARITH_WRONGCONCAT.
        * arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT.
        (gfc_arith_concat):  If the types of op1 and op2 are not
        character of if their kinds do not match, issue ARITH_WRONGCONCAT.

2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/86111
	Backport from trunk
        * gfortran.dg/array_constructor_type_23.f90: New test.


Added:
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/array_constructor_type_23.f90
Modified:
    branches/gcc-8-branch/gcc/fortran/ChangeLog
    branches/gcc-8-branch/gcc/fortran/arith.c
    branches/gcc-8-branch/gcc/fortran/gfortran.h
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 4 Thomas Koenig 2018-10-06 22:42:11 UTC
Fixed.