public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: shuki_duv@yahoo.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/6564: -frepo with function template in anonymous namespace fails to compile
Date: Sun, 05 May 2002 10:16:00 -0000	[thread overview]
Message-ID: <20020505171043.15707.qmail@sources.redhat.com> (raw)


>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>(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 <typename Tp>
  void foo(Tp) {}
}

int
main()
{
  foo(int());
}

[anon2.C - second example]
namespace {
  struct Foo {};
}

template <typename Tp>
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:


             reply	other threads:[~2002-05-05 17:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-05 10:16 shuki_duv [this message]
2002-07-06  7:50 lerdsuwa

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=20020505171043.15707.qmail@sources.redhat.com \
    --to=shuki_duv@yahoo.com \
    --cc=gcc-gnats@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: link
Be 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).