http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47519
Summary: ICE on allocation of with deferred-length string Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: pa...@gcc.gnu.org Follow up to deferred-length string PR 45170. Part of the thread referenced at bug 35810 comment 0, http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/7d5d1e7f4a48071c/7c63fef65ba5ea70?lnk=gst&q=realloc_lhs The following code of James ICEs with the current trunk: foo.f90: In function ‘note7_35’: foo.f90:9:0: internal compiler error: Segmentation fault ==7086== Invalid read of size 8 ==7086== at 0x5B1C46: gfc_trans_allocate (trans-stmt.c:4527) ==7086== by 0x5656E7: trans_code (trans.c:1323) ==7086== by 0x583D91: gfc_generate_function_code (trans-decl.c:4708) ==7086== by 0x527CB7: gfc_parse_file (parse.c:4237) ==7086== by 0x560D75: gfc_be_parse_file (f95-lang.c:250) ==7086== by 0x867FCB: toplev_main (toplev.c:579) ==7086== by 0x64C7BBC: (below main) (libc-start.c:226) ==7086== Address 0x0 is not stack'd, malloc'd or (recently) free'd In the last line of the following (shortened) excerpt the ICE happens: else if (al->expr->ts.type == BT_CHARACTER && al->expr->ts.deferred && code->expr3) { if (!code->expr3->ts.u.cl->backend_decl) { if (code->expr3->expr_type == EXPR_VARIABLE || code->expr3->expr_type == EXPR_CONSTANT) else { gfc_conv_expr (&se_sz, code->ext.alloc.ts.u.cl->length); program note7_35 implicit none character, allocatable :: name*(:) character(*), parameter :: FIRST_NAME = 'Julius' character(*), parameter :: SURNAME = 'No' integer n n = 10 allocate(name, SOURCE=repeat('x',n)) name = 'Dr. '//FIRST_NAME//' '//SURNAME write(*,*) len(name), name deallocate(name) n = 10 allocate(name, SOURCE=repeat('x',n)) name(:) = 'Dr. '//FIRST_NAME//' '//SURNAME write(*,*) len(name), name end program note7_35