public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47674] New: gfortran.dg/realloc_on_assign_5.f03: Segfault at run time
@ 2011-02-10  8:43 burnus at gcc dot gnu.org
  2011-02-12 19:28 ` [Bug fortran/47674] " burnus at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-02-10  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: gfortran.dg/realloc_on_assign_5.f03: Segfault at run
                    time
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: pault@gcc.gnu.org


gfortran.dg/realloc_on_assign_5.f03 segfaults here; it works if I unset the
environment variable MALLOC_CHECK_.

Valgrind shows:

Invalid read of size 1
   at 0x4C285C8: memmove (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x400B41: MAIN__ (realloc_on_assign_5.f03:15)
   by 0x400BF7: main (realloc_on_assign_5.f03:18)
Address 0x5b524c1 is 0 bytes after a block of size 1 alloc'd
   at 0x4C26682: realloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x400B0C: MAIN__ (realloc_on_assign_5.f03:15)
   by 0x400BF7: main (realloc_on_assign_5.f03:18)

Excerpt from the test:
  a = 'ab'   ! OK
  a = (a(2:2)) ! seems to fail
thus
  print '(">",a,"<")', a
prints ">", STX (start of text character), "<" and a new line. Without
MALLOC_CHECK_ the desired ">b<" and a new line is printed.


DUMP: The first "if" does not make sense - at least in this special case - and
there is the issue that "a" is also used on the RHS without using a temporary.

        D.1531 = .a;
        if (D.1531 != 0)
          {
            if ((<unnamed-unsigned:64>) D.1531 <= 1)
              {
                __builtin_memmove (a, &(*a)[2]{lb: 1 sz: 1}, D.1531);
              }
            else
              {
                __builtin_memcpy (a, &(*a)[2]{lb: 1 sz: 1}, 1);
                __builtin_memset (a + 1, 32, D.1531 + 0x0ffffffffffffffff);
              }
          }


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

end of thread, other threads:[~2015-06-04  9:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10  8:43 [Bug fortran/47674] New: gfortran.dg/realloc_on_assign_5.f03: Segfault at run time burnus at gcc dot gnu.org
2011-02-12 19:28 ` [Bug fortran/47674] " burnus at gcc dot gnu.org
2011-08-03  7:24 ` [Bug fortran/47674] gfortran.dg/realloc_on_assign_5.f03: Segfault at run time for deferred (allocatable) string length burnus at gcc dot gnu.org
2013-04-08 20:25 ` tkoenig at gcc dot gnu.org
2013-06-16 20:39 ` dominiq at lps dot ens.fr
2013-09-02 11:18 ` dominiq at lps dot ens.fr
2013-11-23 14:04 ` dominiq at lps dot ens.fr
2014-03-16 10:09 ` tkoenig at gcc dot gnu.org
2014-09-28 21:48 ` bernd.edlinger at hotmail dot de
2014-12-29 17:17 ` tkoenig at gcc dot gnu.org
2015-01-05 17:16 ` tkoenig at gcc dot gnu.org
2015-01-05 19:21 ` tkoenig at gcc dot gnu.org
2015-05-16  6:04 ` tkoenig at gcc dot gnu.org
2015-06-04  9:28 ` tkoenig at gcc dot gnu.org

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