public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "michael dot baudin at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/35959] Recursive function with allocatable array Date: Fri, 18 Apr 2008 15:07:00 -0000 [thread overview] Message-ID: <20080418150702.26477.qmail@sourceware.org> (raw) In-Reply-To: <bug-35959-16071@http.gcc.gnu.org/bugzilla/> [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1259 bytes --] ------- Comment #6 from michael dot baudin at gmail dot com 2008-04-18 15:07 ------- Subject: Re: Recursive function with allocatable array I used the -fdump-tree-original option to compare the version produced on this source code with allocatable and pointer. Only the allocatable contains the following statements : static struct t_type subpattern = {}; subpattern.chars.data = 0B; I understand that the statement " subpattern.chars.data = 0B;" allows to free the array when it goes out of scope, as the standard says about allocatable arrays (which explains why it is not in the pointer version) : if (subpattern.chars.data != 0B) { __builtin_free (subpattern.chars.data); } subpattern.chars.data = 0B; The statement "static struct t_type subpattern = {};", which is not in the pointer version, is the cause of the problem so that the solution is to remove it : at second call, the array has been initialiazed to null, and because it is static, it memory is still deallocated on recursive calls. An allocatable array in a recursive subroutine should not be static (in fortran, that means having the SAVE attribute), isn't it ? Am I right ? Best regards, Michaël -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35959
next prev parent reply other threads:[~2008-04-18 15:07 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-04-16 20:05 [Bug fortran/35959] New: " michael dot baudin at gmail dot com 2008-04-17 6:00 ` [Bug fortran/35959] " pault at gcc dot gnu dot org 2008-04-17 20:38 ` pault at gcc dot gnu dot org 2008-04-18 8:14 ` michael dot baudin at gmail dot com 2008-04-18 14:05 ` jvdelisle at gcc dot gnu dot org 2008-04-18 14:12 ` michael dot baudin at gmail dot com 2008-04-18 15:07 ` michael dot baudin at gmail dot com [this message] 2008-04-19 21:57 ` pault at gcc dot gnu dot org 2008-04-19 22:31 ` pault at gcc dot gnu dot org 2008-04-19 22:33 ` pault at gcc dot gnu dot org 2008-04-24 19:56 ` michael dot baudin 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=20080418150702.26477.qmail@sourceware.org \ --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: linkBe 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).