https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63851
Bug ID: 63851 Summary: ipa-icf miscompiles gfortran.dg/assumed_rank_(8|9|10).f90 at -O2 and above Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: dominiq at lps dot ens.fr CC: fxcoudert at gcc dot gnu.org, iains at gcc dot gnu.org, marxin at gcc dot gnu.org On x86_64-apple-darwin14 ipa-icf miscompiles gfortran.dg/assumed_rank_(8|9|10).f90 at -O2 and above (see pr63622 comment 7). Reduced test for assumed_rank_8.f90 [Book15] f90/bug% cat assumed_rank_8_red.f90 program main implicit none interface subroutine check (x) integer :: x(..) end subroutine check end interface integer, allocatable :: kk integer, pointer :: ll call g (null()) kk = 489 call h (kk) contains subroutine g (x) integer, pointer, intent(in) :: x(..) call check (x) end subroutine subroutine h (x) integer, allocatable :: x(..) call check (x) end subroutine end program main [Book15] f90/bug% cat assumed_rank_8_c_red.c /* Called by assumed_rank_8.f90 and assumed_rank_9.f90. */ #include <stdlib.h> /* For abort(). */ struct a { int *dat; }; void check_ (struct a *x) { if (*x->dat != 489) abort (); } [Book15] f90/bug% gfc -O2 assumed_rank_8_red.f90 assumed_rank_8_c_red.c [Book15] f90/bug% a.out Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10ec7a5c2 #1 0x10ec7ad60 #2 0x7fff81c71f19 #3 0x10ec71e73 #4 0x10ec71eb5 Segmentation fault If I comment the first 'call check (x)', the abort goes away. A reduced test for assumed_rank_10.f90 (fails only with -m32) has been posted in pr63622 comment 34.