http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60576

--- Comment #15 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Reduced test case failing on x86_64-apple-darwin13 r208927 with -m64 (4.9.0 and
4.8.3, it succeeds with -m32 as well as the original test).

[Book15] f90/bug% cat assumed_rank_7_red.f90
implicit none
type t
  integer :: i
end type

class(T), allocatable :: ac(:,:)
type(T), allocatable :: at(:,:)

allocate(ac(2:3,2:4))
allocate(at(2:3,2:4))

call bar(ac)

contains
  subroutine bar(x)
    type(t) :: x(..)
    call foo(x)
  end subroutine
  subroutine foo(x)
    class(t) :: x(..)
  end subroutine
end 
[Book15] f90/bug% gfc assumed_rank_7_red.f90 -fsanitize=address
[Book15] f90/bug% a.out
=================================================================
==40254==ERROR: AddressSanitizer: stack-buffer-underflow on address
0x7fff587043c0 at pc 0x10751d678 bp 0x7fff58704230 sp 0x7fff58704208
READ of size 192 at 0x7fff587043c0 thread T0
    #0 0x10751d677 (/opt/gcc/gcc4.9w/lib/libasan.1.dylib+0x1a677)
    #1 0x1074fc968
(/Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/a.out+0x100001968)
    #2 0x1074fc6c7
(/Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/a.out+0x1000016c7)
    #3 0x1074fc9af
(/Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/a.out+0x1000019af)
    #4 0x7fff960745fc (/usr/lib/system/libdyld.dylib+0x35fc)
    #5 0x0

Address 0x7fff587043c0 is located in stack of thread T0 at offset 0 in frame
    #0 0x1074fc1fe
(/Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/a.out+0x1000011fe)

  This frame has 1 object(s):
    [32, 104) 'at' <== Memory access at offset 0 partially underflows this
variable
HINT: this may be a false positive if your program uses some custom stack
unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-underflow ??:0 ??
Shadow bytes around the buggy address:
  0x1fffeb0e0820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e0830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e0840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e0850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e0860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1fffeb0e0870: 00 00 00 00 00 00 00 00[f1]f1 f1 f1 00 00 00 00
  0x1fffeb0e0880: 00 00 00 00 00 f4 f4 f4 f3 f3 f3 f3 00 00 00 00
  0x1fffeb0e0890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e08a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e08b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb0e08c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Contiguous container OOB:fc
  ASan internal:           fe
==40254==ABORTING

The code executes without error if I comment the line

allocate(at(2:3,2:4))

Reply via email to