[gcc-3.0 bug?] C++ symbols treated as C

Andrey Slepuhin pooh@msu.ru
Tue Apr 24 03:29:00 GMT 2001


On Mon, Apr 23, 2001 at 09:34:15AM +0400, Andrey Slepuhin wrote:
> Hi,
> 
> Trying to upgrade from 20010311 to 20010419 gcc snapshot
> (taken from CodeSourcery) I got undefined references
> when linking my C++ code. Looking into assembler output I see the
> things like following:

[snip]

Ok, I found a test case which localizes a problem.
Compiling the following program with 20010422 snapshot:

-------------------------------------------------------
#include <cstdio>

namespace A
{

int abcdef;

template <typename val_t>
class X
{
public:
  inline X ()
  {
    extern int abcdef;
    printf("%d\n", abcdef);
  }
};

}

using namespace A;

int main (int argc, char* argv[])
{
  X<int> x;
  return 0;
}
------------------------------------------------------------

I got the following error:
/tmp/ccWmhmdS.o: In function `A::X<int>::X()':
/tmp/ccWmhmdS.o(.gnu.linkonce.t._ZN1A1XIiEC1Ev+0xb): undefined reference to
`abcdef'
collect2: ld returned 1 exit status

Assembler output shows that "extern int abcdef;" is not considered as a member
of namespace A. 20010311 snapshot compiles this program without errors.
Making X non-template class also removes errors.

Regards,
Andrey.

-- 
A right thing should be simple (tm)



More information about the Gcc mailing list