public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43178]  New: Pointless resetting to NULLify for local ALLOCATABLEs
@ 2010-02-25 17:09 burnus at gcc dot gnu dot org
  2010-02-25 23:51 ` [Bug fortran/43178] Pointless resetting to NULL " burnus at gcc dot gnu dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-25 17:09 UTC (permalink / raw)
  To: gcc-bugs

Somehow there is a completely pointless default initialization for
allocatables:

  static struct t foo = {};  // with "subroutine" one has: "struct t foo;"
  foo.a.data = 0B;

    D.1557 = foo;
    if (D.1557.a.data != 0B)
        __builtin_free ((void *) D.1557.a.data);
    D.1557.a.data = 0B;

Expected: If the variables is local, there is no need for the lines after
"foo.a.data = 0B;". It completely unnecessarily clutters the dump and might
confuse the middle end.

 * * *

Second bug: And if the variable is STATIC (module variables, main program, and
SAVE) there is also no need for the
  foo.a.data = 0B;
Actually, if one marks "foo" explicitly as SAVE in the example below, only
  static struct t foo = {};
remains. As PROGRAM implies SAVE this should have been the result for PROGRAM
even without SAVE. (This implication is new in F2008, but already now "foo" is
static. One could do the check based on TREE_STATIC() instead of using attr.*.

Test case:

!!! subroutine sub() ! << variant, which does not imply SAVE
type t
  integer, allocatable :: a(:)
end type t
type(t) :: foo
if (allocated(foo%a)) call abort() ! Use the variable
end


-- 
           Summary: Pointless resetting to NULLify for local ALLOCATABLEs
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

end of thread, other threads:[~2010-04-06 12:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-25 17:09 [Bug fortran/43178] New: Pointless resetting to NULLify for local ALLOCATABLEs burnus at gcc dot gnu dot org
2010-02-25 23:51 ` [Bug fortran/43178] Pointless resetting to NULL " burnus at gcc dot gnu dot org
2010-02-26  7:44 ` burnus at gcc dot gnu dot org
2010-02-26 14:30 ` dominiq at lps dot ens dot fr
2010-02-26 14:38 ` dominiq at lps dot ens dot fr
2010-02-26 16:29 ` dominiq at lps dot ens dot fr
2010-02-26 16:37 ` burnus at gcc dot gnu dot org
2010-02-26 19:27 ` dominiq at lps dot ens dot fr
2010-02-26 19:37 ` dominiq at lps dot ens dot fr
2010-02-26 21:08 ` dominiq at lps dot ens dot fr
2010-02-26 23:20 ` burnus at gcc dot gnu dot org
2010-02-27 10:36 ` dominiq at lps dot ens dot fr
2010-02-27 12:25 ` burnus at gcc dot gnu dot org
2010-02-28 11:20 ` dominiq at lps dot ens dot fr
2010-02-28 17:30 ` burnus at gcc dot gnu dot org
2010-02-28 19:48 ` burnus at gcc dot gnu dot org
2010-03-27 18:53 ` pault at gcc dot gnu dot org
2010-04-06 12:47 ` burnus at gcc dot gnu dot org
2010-04-06 12:48 ` burnus at gcc dot gnu dot 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).