I get an "undefined reference" error with a recent gcc 4.2 when linking to a
class whose header contains an additional namespace that is references from
that class.  This is a very recent error.  It started to occur between 20060626
and 20060709.

(sid)1690:[EMAIL PROTECTED]: ~/src/t] make
rm -f *.o
g++-4.1 -c t.cc ; g++-4.1 -c a.c ; g++-4.1  a.o t.o
rm -f *.o
g++-4.2 -c t.cc ; g++-4.2 -c a.c ; g++-4.2  a.o t.o
a.o: In function `main':
a.c:(.text+0x18): undefined reference to `test::MonitorHandle::MonitorHandle()'
collect2: ld returned 1 exit status
(sid)1691:[EMAIL PROTECTED]: ~/src/t] cat t.h
namespace test
{

namespace
{
class SignalProxy_Monitor;
}

class MonitorHandle
{
public:
  MonitorHandle();

private:
  SignalProxy_Monitor* proxy_;

};

}
(sid)1693:[EMAIL PROTECTED]: ~/src/t] cat t.cc
#include "t.h"

namespace test
{

MonitorHandle::MonitorHandle()
{}

}

(sid)1694:[EMAIL PROTECTED]: ~/src/t] cat a.c
#include "t.h"

int main(void) {
        test::MonitorHandle handle;
        return 0;
}


-- 
           Summary: [4.2 regression] undefined reference when header
                    contains additional namespace
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tbm at cyrius dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28360

Reply via email to