[Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Tue Feb 7 22:03:00 GMT 2012


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

             Bug #: 52162
           Summary: Bogus -fcheck=bounds with realloc on assignment to
                    unallocated LHS
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dominiq@lps.ens.fr


The test gfortran.dg/realloc_on_assign_2.f0 fails at runtime when compiled with
-fcheck=bounds:

At line 57 of file
/opt/gcc/work/gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03
Fortran runtime error: Array bound mismatch for dimension 1 of array 'a' (10/2)

The following reduced test

    integer(4), allocatable :: a(:)
    integer(8), allocatable :: b(:)
    allocate (b(7:11))
    a = b
    if (lbound (a, 1) .ne. lbound(b, 1)) call abort
    if (ubound (a, 1) .ne. ubound(b, 1)) call abort
  end

fails with

At line 4 of file realloc_on_assign_2_red.f03
Fortran runtime error: Array bound mismatch for dimension 1 of array 'a' (0/5)

Running the executable through valgrind yields

==78996== Memcheck, a memory error detector
==78996== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==78996== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==78996== Command: a.out
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x1000018FC: MAIN__ (realloc_on_assign_2_red.f03:4)
==78996==    by 0x100001C94: main (realloc_on_assign_2_red.f03:7)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x100001948: MAIN__ (realloc_on_assign_2_red.f03:4)
==78996==    by 0x100001C94: main (realloc_on_assign_2_red.f03:7)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x100001994: MAIN__ (realloc_on_assign_2_red.f03:4)
==78996==    by 0x100001C94: main (realloc_on_assign_2_red.f03:7)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x1000019DD: MAIN__ (realloc_on_assign_2_red.f03:4)
==78996==    by 0x100001C94: main (realloc_on_assign_2_red.f03:7)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x100001A2C: MAIN__ (realloc_on_assign_2_red.f03:4)
==78996==    by 0x100001C94: main (realloc_on_assign_2_red.f03:7)
==78996== 
At line 4 of file realloc_on_assign_2_red.f03
Fortran runtime error: ==78996== Conditional jump or move depends on
uninitialised value(s)
==78996==    at 0x10019559E: __vfprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x1001C95B6: vsnprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x100021759: _gfortrani_st_vprintf (in
/opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE72F: ???
==78996==    by 0x7FFF5FC12DBF:
ImageLoaderMachOCompressed::resolve(ImageLoader::LinkContext const&, char
const*, unsigned char, int, ImageLoader const**,
ImageLoaderMachOCompressed::LastLookup*) (in /usr/lib/dyld)
==78996==    by 0x7FFF5FBFE73F: ???
==78996==    by 0x7FFF5FC4049F: ??? (in /usr/lib/dyld)
==78996==    by 0x7FFF5FC43EDF: ???
==78996==    by 0x10012FF91: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE887: ???
==78996==    by 0x10012FF99: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x10012FFC7: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x100196D06: __vfprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x1001C95B6: vsnprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x100021759: _gfortrani_st_vprintf (in
/opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE72F: ???
==78996==    by 0x7FFF5FC12DBF:
ImageLoaderMachOCompressed::resolve(ImageLoader::LinkContext const&, char
const*, unsigned char, int, ImageLoader const**,
ImageLoaderMachOCompressed::LastLookup*) (in /usr/lib/dyld)
==78996==    by 0x7FFF5FBFE73F: ???
==78996==    by 0x7FFF5FC4049F: ??? (in /usr/lib/dyld)
==78996==    by 0x7FFF5FC43EDF: ???
==78996==    by 0x10012FF91: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE887: ???
==78996==    by 0x10012FF99: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x10012FFC7: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996== 
==78996== Conditional jump or move depends on uninitialised value(s)
==78996==    at 0x1002545AD: __ultoa (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x100196D76: __vfprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x1001C95B6: vsnprintf (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x100021759: _gfortrani_st_vprintf (in
/opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE72F: ???
==78996==    by 0x7FFF5FC12DBF:
ImageLoaderMachOCompressed::resolve(ImageLoader::LinkContext const&, char
const*, unsigned char, int, ImageLoader const**,
ImageLoaderMachOCompressed::LastLookup*) (in /usr/lib/dyld)
==78996==    by 0x7FFF5FBFE73F: ???
==78996==    by 0x7FFF5FC4049F: ??? (in /usr/lib/dyld)
==78996==    by 0x7FFF5FC43EDF: ???
==78996==    by 0x10012FF91: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FBFE887: ???
==78996==    by 0x10012FF99: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996== 
==78996== Syscall param write(buf) points to uninitialised byte(s)
==78996==    at 0x10019A272: write (in /usr/lib/libSystem.B.dylib)
==78996==    by 0x100021769: _gfortrani_st_vprintf (in
/opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x6F62207961727240: ???
==78996==    by 0x6D73696D20646E74: ???
==78996==    by 0x726F662068637460: ???
==78996==    by 0x69736E656D69641F: ???
==78996==    by 0x20666F2031206E6E: ???
==78996==    by 0x6127207961727260: ???
==78996==    by 0x29352F30282026: ???
==78996==    by 0x10012FF99: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x10012FFC7: ??? (in /opt/gcc/gcc4.7w/lib/libgfortran.3.dylib)
==78996==    by 0x7FFF5FC43EDF: ???
==78996==  Address 0x7fff5fbfe703 is on thread 1's stack
==78996== 
Array bound mismatch for dimension 1 of array 'a' (0/5)
==78996== 
==78996== HEAP SUMMARY:
==78996==     in use at exit: 128 bytes in 2 blocks
==78996==   total heap usage: 18 allocs, 16 frees, 4,029 bytes allocated
==78996== 
==78996== LEAK SUMMARY:
==78996==    definitely lost: 0 bytes in 0 blocks
==78996==    indirectly lost: 0 bytes in 0 blocks
==78996==      possibly lost: 0 bytes in 0 blocks
==78996==    still reachable: 40 bytes in 1 blocks
==78996==         suppressed: 88 bytes in 1 blocks
==78996== Rerun with --leak-check=full to see details of leaked memory
==78996== 
==78996== For counts of detected and suppressed errors, rerun with: -v
==78996== Use --track-origins=yes to see where uninitialised values come from
==78996== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)



More information about the Gcc-bugs mailing list