public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52418] New: (unnecessary) automatic reallocation of lhs causes segfault
@ 2012-02-28 16:12 therobbot at gmail dot com
  2012-02-28 16:34 ` [Bug fortran/52418] " burnus at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: therobbot at gmail dot com @ 2012-02-28 16:12 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52418
           Summary: (unnecessary) automatic reallocation of lhs causes
                    segfault
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: therobbot@gmail.com


Created attachment 26771
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26771
program to reproduce bug

The following program causes a segfault:

PROGRAM reshape_test
  IMPLICIT NONE
  REAL, DIMENSION(:,:), ALLOCATABLE :: m2
  REAL, DIMENSION(:,:,:), ALLOCATABLE :: m3
  ALLOCATE( m2( 6, 1 ), m3( 2, 3, 1 ) )
  m2 = -1
  m3 = RESHAPE( m2, SHAPE(m3) )
  m3 = 2
  WRITE(*,*) 'm3(1,1,1) = ', m3(1,1,1)
END PROGRAM reshape_test

If compiled with -fno-realloc-lhs, the code runs as expected. There really
shouldn't be any reallocation here, so this shouldn't make a difference. Either
way it should not cause a segfault.

Side note: I love all of the work on f2003/2008! The OO features make fortran
fun again. Thanks!


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

* [Bug fortran/52418] (unnecessary) automatic reallocation of lhs causes segfault
  2012-02-28 16:12 [Bug fortran/52418] New: (unnecessary) automatic reallocation of lhs causes segfault therobbot at gmail dot com
@ 2012-02-28 16:34 ` burnus at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-28 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |burnus at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-28 16:25:26 UTC ---
Aha, that's the bug report to the spurious attachment at PR 48058 comment 4.
Thanks for the bug report and sorry for the breakage!


As written there, that's a known bug affecting both GCC 4.6 and GCC 4.7. It has
been reported on 2012-01-26 and fixed on 2012-01-31 for GCC 4.7 and on
2012-02-03 for GCC 4.7 [See PR 52151 for details.]

A follow up fix (for RESHAPE when a reallocation is required) has been
committed on 2012-02-08 for both GCC's 4.6 branch and the 4.7 trunk, cf. PR
52151.


(For some reasons, no one has reported the bug for one year, but now there were
two reports within a week and this one a month after the first report.)


As written in PR 52117, you have the following options:

> Unless you provide me with a time machine [...]
> The only solutions, I see, which do not require code changes are:
> 
> - Use any GCC version before GCC 4.6.0; for instance GCC 4.5.x
> - Use GCC 4.6 older than 2010-11-28
> - Use a GCC (any version) newer than 2012-02-03
> - Use -fno-realloc-lhs (caveat: Flag not supported before GCC 4.6)
> - Use -std=f95 (caveat: Requires that the code compiles without error with
> -std=f95)

> For completeness, also the following code changes are possible; except for
> the first one, they are not recommended:
> 
> - Use an array spec for allocatable LHS, e.g. "B(:,:,:) = "
[And some more nonseriously meant variants]

*** This bug has been marked as a duplicate of bug 52151 ***


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

end of thread, other threads:[~2012-02-28 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 16:12 [Bug fortran/52418] New: (unnecessary) automatic reallocation of lhs causes segfault therobbot at gmail dot com
2012-02-28 16:34 ` [Bug fortran/52418] " burnus 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).