public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
@ 2012-02-07 22:03 dominiq at lps dot ens.fr
  2012-02-09 17:20 ` [Bug fortran/52162] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-02-07 22:03 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
  2012-02-07 22:03 [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS dominiq at lps dot ens.fr
@ 2012-02-09 17:20 ` burnus at gcc dot gnu.org
  2012-02-09 17:28 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-09 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-09 17:17:03 UTC ---
    a = b

The problem is that the LHS is REAL(4) while the RHS is REAL(8). Thus, the
expression is not <variable A> = <variable B> but
  <variable A> = __convert_i8_i4 (<variable B>)


But trans-array's gfc_trans_assignment_1 contains:

  if (gfc_is_reallocatable_lhs (expr1)
    && !(expr2->expr_type == EXPR_FUNCTION
         && expr2->value.function.isym != NULL))
    lss->is_alloc_lhs = 1;

As expr2->value.function.isym is set (expr2->value.function.isym->id ==
GFC_ISYM_CONVERSION), the is_alloc_lhs is not set. Hence, the bound checking
code is inserted.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
  2012-02-07 22:03 [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS dominiq at lps dot ens.fr
  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
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-09 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-09 17:27:26 UTC ---
(In reply to comment #1)
> As expr2->value.function.isym is set (expr2->value.function.isym->id ==
> GFC_ISYM_CONVERSION), the is_alloc_lhs is not set. Hence, the bound checking
> code is inserted.

All intrinsics, which do not call libgfortran, should be affected. For
instance:
  B = tan(A)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
  2012-02-07 22:03 [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS dominiq at lps dot ens.fr
  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
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-09-22 22:29 UTC (permalink / raw)
  To: gcc-bugs


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-22
     Ever Confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-09-22 22:29:00 UTC ---
>From comments #1 and #2, I assume that this PR is confirmed, so I set the
status to NEW.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
  2012-02-07 22:03 [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS dominiq at lps dot ens.fr
                   ` (2 preceding siblings ...)
  2012-09-22 22:29 ` dominiq at lps dot ens.fr
@ 2015-08-13 14:34 ` a.rohou at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: a.rohou at gmail dot com @ 2015-08-13 14:34 UTC (permalink / raw)
  To: gcc-bugs

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

Alexis Rohou <a.rohou at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |a.rohou at gmail dot com

--- Comment #4 from Alexis Rohou <a.rohou at gmail dot com> ---
I'm also affected by this bug, in gfortran 5.1.1 20150618 (Red Hat 5.1.1-4).


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-13 14:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-07 22:03 [Bug fortran/52162] New: Bogus -fcheck=bounds with realloc on assignment to unallocated LHS dominiq at lps dot ens.fr
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

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).