public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6564: -frepo with function template in anonymous namespace fails to compile
@ 2002-07-06  7:50 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-07-06  7:50 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, shuki_duv

Synopsis: -frepo with function template in anonymous namespace fails to compile

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Jul  6 07:50:42 2002
State-Changed-Why:
    Fixed in 3.1 branch and trunk.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6564


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/6564: -frepo with function template in anonymous namespace fails to compile
@ 2002-05-05 10:16 shuki_duv
  0 siblings, 0 replies; 2+ messages in thread
From: shuki_duv @ 2002-05-05 10:16 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-06 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-06  7:50 c++/6564: -frepo with function template in anonymous namespace fails to compile lerdsuwa
  -- strict thread matches above, loose matches on Subject: below --
2002-05-05 10:16 shuki_duv

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).