Bug 29417 - [4.2 Regression] link fails with debug and anonymous namespace
Summary: [4.2 Regression] link fails with debug and anonymous namespace
Status: RESOLVED DUPLICATE of bug 27657
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P1 critical
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: link-failure
Depends on: 27657
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-10 16:16 UTC by Peter Naulls
Modified: 2006-10-20 07:42 UTC (History)
11 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-11 02:48:51


Attachments
minimal test case (105.42 KB, text/plain)
2006-10-10 16:17 UTC, Peter Naulls
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Naulls 2006-10-10 16:16:11 UTC
This is with:

gcc (GCC) 4.2.0 20061007 (experimental)

On x86 Debian and under Fedora Core 3.

Using the lamba part of the boost library, the following is seen:


/tmp/ccNdhcXx.o:(.debug_info+0xec9): undefined reference to `boost::lambda::(anonymous namespace)::free2'
/tmp/ccNdhcXx.o:(.debug_info+0xed8): undefined reference to `boost::lambda::(anonymous namespace)::free3'
/tmp/ccNdhcXx.o:(.debug_info+0x47f2): undefined reference to `boost::lambda::(anonymous namespace)::free2'
/tmp/ccNdhcXx.o:(.debug_info+0x4806): undefined reference to `boost::lambda::(anonymous namespace)::free3'

I don't think the fault is in the boost library.  Here is the code in question:

namespace {

  // These are constants types and need to be initialised
  boost::lambda::placeholder1_type free1 = boost::lambda::placeholder1_type();
  boost::lambda::placeholder2_type free2 = boost::lambda::placeholder2_type();
  boost::lambda::placeholder3_type free3 = boost::lambda::placeholder3_type();

  boost::lambda::placeholder1_type& _1 = free1;
  boost::lambda::placeholder2_type& _2 = free2;
  boost::lambda::placeholder3_type& _3 = free3;
  // _1, _2, ... naming scheme by Peter Dimov
} // unnamed

To trigger the problem requires at least -O and -g2.  My C++ isn't good enough to comment further.  I attach a minimal preprocessed case.  compile with:

g++-4.2 test.ii -O -g2 

This works correctly on previous GCC versions, and with -g1.
Comment 1 Peter Naulls 2006-10-10 16:17:29 UTC
Created attachment 12405 [details]
minimal test case
Comment 2 Andrew Pinski 2006-10-11 01:21:48 UTC
Reducing.
Comment 3 Andrew Pinski 2006-10-11 02:48:51 UTC
Reduced testcase:
template <int>
struct lambda_functor 
{
  lambda_functor() {}
};
namespace {
lambda_functor<2 > free2;
lambda_functor<3 > free3;
lambda_functor<3 > & _3 = free3;
}
int main (void){}
Comment 4 Andrew Pinski 2006-10-11 02:50:46 UTC
I think this is related to PR 27657.
Comment 5 Janis Johnson 2006-10-17 16:25:58 UTC
A regression hunt on powerpc-linux identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=115086

    r115086 | jason | 2006-06-30 01:15:56 +0000 (Fri, 30 Jun 2006)
Comment 6 Andrew Pinski 2006-10-20 07:42:06 UTC
(In reply to comment #5)
> A regression hunt on powerpc-linux identified the following patch:

This just confirms the problem here is the same as listed in PR 27657 as that patch cause anonymous namespace to be local linkage. Closing as a dup of PR 27657.

*** This bug has been marked as a duplicate of 27657 ***