http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56136
Bug #: 56136 Summary: Compiler fails when code contains lhs-reallocation of an object with overloaded (elemental) Assignment operator Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: alipasha.cele...@gmail.com Created attachment 29299 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29299 The code that causes compiler crash Upon compiling the following code using GNU Fortran (GCC) 4.8.0 20130128 (experimental): MODULE A_TEST_M TYPE :: A_TYPE CONTAINS GENERIC :: ASSIGNMENT (=) => ASGN_A PROCEDURE, PRIVATE :: ASGN_A END TYPE CONTAINS ELEMENTAL SUBROUTINE ASGN_A (A, B) CLASS (A_TYPE), INTENT (INOUT) :: A CLASS (A_TYPE), INTENT (IN) :: B END SUBROUTINE END MODULE A_TEST_M PROGRAM ASGN_REALLOC_TEST USE A_TEST_M TYPE (A_TYPE), ALLOCATABLE :: A(:) ALLOCATE (A(100)) A(1:50) = A(51:100) A = A(1:50) END PROGRAM placed in file "asgn_realloc_test.f" with compile call: user@machine:~/../quicktest$ gfortran asgn_realloc_test.f causes compiler to crash with the following messages: asgn_realloc_test.f: In function ‘test’: asgn_realloc_test.f:22:0: internal compiler error: in gfc_conv_variable, at fortran/trans-expr.c:1658 A = A(1:50) ^ 0x5db000 gfc_conv_variable ../.././gcc/fortran/trans-expr.c:1658 0x5d75ca gfc_conv_expr(gfc_se*, gfc_expr*) ../.././gcc/fortran/trans-expr.c:6263 0x5dbef3 gfc_conv_expr_reference(gfc_se*, gfc_expr*) ../.././gcc/fortran/trans-expr.c:6357 0x5dc2fa gfc_conv_derived_to_class(gfc_se*, gfc_expr*, gfc_typespec, tree_node*, bool, bool) ../.././gcc/fortran/trans-expr.c:305 0x5d426a gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*, gfc_expr*, vec<tree_node*, va_gc, vl_embed>*) ../.././gcc/fortran/trans-expr.c:4087 0x5ff84c gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool) ../.././gcc/fortran/trans-stmt.c:491 0x5a4663 trans_code ../.././gcc/fortran/trans.c:1511 0x5cb57e gfc_generate_function_code(gfc_namespace*) ../.././gcc/fortran/trans-decl.c:5390 0x564390 translate_all_program_units ../.././gcc/fortran/parse.c:4463 0x564390 gfc_parse_file() ../.././gcc/fortran/parse.c:4677 0x59fe75 gfc_be_parse_file ../.././gcc/fortran/f95-lang.c:189 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. Note that the line before the reallocating assignment (A(1:50) = A(51:100)) will not cause errors. Compiler was configured using: sudo LIBRARY_PATH=/usr/lib/x86_64-linux-gnu ./configure --enable-languages=c,c++,fortran --enable-libgomp --enable-lto --enable-gold --with-plugin-ld=/usr/bin/gold on Ubuntu: Release 12.04 (precise) 64-bit Kernel Linux 3.2.0-36-generic