From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17706 invoked by alias); 5 May 2002 17:16:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 17674 invoked by uid 71); 5 May 2002 17:16:01 -0000 Resent-Date: 5 May 2002 17:16:01 -0000 Resent-Message-ID: <20020505171601.17673.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, shuki_duv@yahoo.com Received:(qmail 15708 invoked by uid 61); 5 May 2002 17:10:43 -0000 Message-Id:<20020505171043.15707.qmail@sources.redhat.com> Date: Sun, 05 May 2002 10:16:00 -0000 From: shuki_duv@yahoo.com Reply-To: shuki_duv@yahoo.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/6564: -frepo with function template in anonymous namespace fails to compile X-SW-Source: 2002-05/txt/msg00126.txt.bz2 List-Id: >Number: 6564 >Category: c++ >Synopsis: -frepo with function template in anonymous namespace fails to compile >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Sun May 05 10:16:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Shimshon Duvdevan >Release: gcc version 3.0.4, Thread model: posix >Organization: >Environment: sparc-sun-solaris2.6 (bug irrelevant to platform) >Description: A function template is defined in anonymous namespace, and is called from global namespace. When trying to compile with -frepo, the recompiling/relinking goes on indefinitely, until done 17 times (regardless of -ftemplate-depth-n): [these are the commands for the first example, second is similar] $ g++ -frepo -Wall -c -o anon.o anon.C $ g++ -frepo -Wall -o anon anon.o collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking collect: recompiling anon.C collect: relinking Undefined first referenced symbol in file void (anonymous namespace)::foo(int)anon.o ld: fatal: Symbol referencing errors. No output written to anon collect2: ld returned 1 exit status >How-To-Repeat: [anon.C - first example] namespace { template void foo(Tp) {} } int main() { foo(int()); } [anon2.C - second example] namespace { struct Foo {}; } template void foo(Tp) {} int main() { foo(Foo()); } >Fix: Inlining the function explicitly or implicitly (via -O3) makes the problem go away, but only because the function is, well, inlined. Using static qualifier instead of the anonymous namespace fixes the problem in the first case, but then there are scenarios that are not fixable in this way, such as a function template (not in anonymous namespace), whose parameter is a class which is defined in an anonymous namespace, see second example. >Release-Note: >Audit-Trail: >Unformatted: