From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21128 invoked by alias); 24 Jul 2010 13:08:28 -0000 Received: (qmail 18011 invoked by uid 48); 24 Jul 2010 13:08:15 -0000 Date: Sat, 24 Jul 2010 13:08:00 -0000 Message-ID: <20100724130815.18008.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/40011] Problems with -fwhole-file In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus 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: 2010-07/txt/msg02636.txt.bz2 ------- Comment #65 from burnus at gcc dot gnu dot org 2010-07-24 13:08 ------- (In reply to comment #64) > Failure with -fwhole-file: > /tmp/ccN7F1tB.o: In function `__mod_MOD_four': > test.f90:(.text+0x3): undefined reference to `one_' If one sets a breakpoint in gfc_create_function_decl, gfc_generate_function_code, and gfc_get_extern_function_decl one has: ... gfc_get_extern_function_decl "two" <--- (1) ---> gfc_generate_function_code "two" ... In between those functions calls, the gfc_global_ns_list changes from: "two"->"one" to "two"->"MAIN__". If I add the following patch, it works with the reduced test case and seems to also work with the one-file CP2K. I wonder why this problem did not show up before. It seems to be pretty obvious and not restricted to -fwhole-file (though, the chance of miscompilation is much increased with -fwhole-file). Index: parse.c =================================================================== --- parse.c (Revision 162498) +++ parse.c (Arbeitskopie) @@ -4414,7 +4414,11 @@ later and all their interfaces resolved. */ gfc_current_ns->code = s.head; if (next) - next->sibling = gfc_current_ns; + { + for (; next->sibling; next = next->sibling) + ; + next->sibling = gfc_current_ns; + } else gfc_global_ns_list = gfc_current_ns; -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |burnus at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2009-12-09 11:50:57 |2010-07-24 13:08:14 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40011