From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12162 invoked by alias); 27 Sep 2009 17:21:21 -0000 Received: (qmail 11942 invoked by uid 48); 27 Sep 2009 17:20:57 -0000 Date: Sun, 27 Sep 2009 17:21:00 -0000 Message-ID: <20090927172057.11941.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/41479] [4.3/4.4/4.5 Regression] intent(out) for types with default initialization In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "kargl at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg02494.txt.bz2 ------- Comment #6 from kargl at gcc dot gnu dot org 2009-09-27 17:20 ------- (In reply to comment #0) > The example below shows that besides the fact that declared as INTENT(OUT) the > component 'n' is not initialized per default the second time. It's not initialized on the first call to INIT(), either. Form -fdump-tree-original init (struct container_t & restrict container) { if (container != 0) { if (container->a.data != 0B) { __builtin_free ((void *) container->a.data); } container->a.data = 0B; } } There is no assignment here. If we look at MAIN MAIN__ () { static struct container_t container = {.n=4242}; static void init (struct container_t & restrict); static void dump (struct container_t & restrict); container.a.data = 0B; { struct container_t D.1317; struct container_t container_t.1; container_t.1.n = 4242; container_t.1.a.data = 0B; D.1317 = container; container = container_t.1; if (D.1317.a.data != 0B) { __builtin_free ((void *) D.1317.a.data); } D.1317.a.data = 0B; } init (&container); dump (&container); container.n = 1; dump (&container); init (&container); we see the n = 4242 (I changed the value to 4242) from the original declaration statement. On a side note, if integer, dimension(:), allocatable :: a is replaced with integer, dimension(:), pointer :: a we get REMOVE:kargl[272] ./z value = 4242 value = 1 value = 4242 and -fdump-tree-original shows init (struct container_t & restrict container) { if (container != 0) { { struct container_t D.1311; struct container_t container_t.1; container_t.1.n = 4242; D.1311 = container_t.1; *container = D.1311; } } } I suspect that this has been broken since allocatable component were introduced into gfortran. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41479