public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
Date: Tue, 07 Feb 2012 22:03:00 -0000	[thread overview]
Message-ID: <bug-52162-4@http.gcc.gnu.org/bugzilla/> (raw)

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)


             reply	other threads:[~2012-02-07 22:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 22:03 dominiq at lps dot ens.fr [this message]
2012-02-09 17:20 ` [Bug fortran/52162] " burnus at gcc dot gnu.org
2012-02-09 17:28 ` burnus at gcc dot gnu.org
2012-09-22 22:29 ` dominiq at lps dot ens.fr
2015-08-13 14:34 ` a.rohou at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52162-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).