http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56789
Bug #: 56789 Summary: Wrong code with contiguous dummy argument Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: tkoe...@gcc.gnu.org This is from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41137#c15 ig25@linux-fd1f:~/Krempel/Contig> cat foo.f90 module zero implicit none contains subroutine foo(a) real, contiguous :: a(:,:) a(:,:) = 0 end subroutine foo end module zero program main use zero implicit none real, dimension(5,5) :: a a = 1. call foo(a(1:5:2,1:5:2)) ! write (*,'(5F12.5)') a end program main ig25@linux-fd1f:~/Krempel/Contig> gfortran foo.f90 ig25@linux-fd1f:~/Krempel/Contig> ./a.out *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x0000000000629f90 *** a.out: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed. Program received signal SIGABRT: Process abort signal. Backtrace for this error: [...] ig25@linux-fd1f:~/Krempel/Contig> valgrind ./a.out ==19631== Memcheck, a memory error detector ==19631== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==19631== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==19631== Command: ./a.out ==19631== ==19631== Invalid write of size 4 ==19631== at 0x4007F7: __zero_MOD_foo (in /home/ig25/Krempel/Contig/a.out) ==19631== by 0x4008E8: MAIN__ (in /home/ig25/Krempel/Contig/a.out) ==19631== by 0x40095A: main (in /home/ig25/Krempel/Contig/a.out) ==19631== Address 0x5c38428 is 4 bytes after a block of size 36 alloc'd ==19631== at 0x4C2ABED: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19631== by 0x4E4C714: _gfortrani_xmalloc (memory.c:38) ==19631== by 0x4EE9B23: _gfortrani_internal_pack_r4 (in_pack_r4.c:79) ==19631== by 0x4008CF: MAIN__ (in /home/ig25/Krempel/Contig/a.out) ==19631== by 0x40095A: main (in /home/ig25/Krempel/Contig/a.out) ==19631== ==19631== ==19631== HEAP SUMMARY: ==19631== in use at exit: 0 bytes in 0 blocks ==19631== total heap usage: 22 allocs, 22 frees, 11,858 bytes allocated ==19631== ==19631== All heap blocks were freed -- no leaks are possible ==19631== ==19631== For counts of detected and suppressed errors, rerun with: -v ==19631== ERROR SUMMARY: 6 errors from 1 contexts (suppressed: 2 from 2)