bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ 2.95.3 Bug Report


From: jgentilesco
Subject: g++ 2.95.3 Bug Report
Date: Tue, 14 Aug 2001 11:45:43 -0400

Compiler: GNU g++ 2.95.3
--------
OS:       Solaris 2.8 
--
HW:       Sun UltraSparc 60
--

===========================================================================

Bug Report:
----------

If the definition of a static class data member is placed in a header
file, which is subsequently included by multiple source files, the
compiler/linker does not issue a "multiply-defined" symbol error message as
expected.
However, if the static variable is explicitly initialized, then the
error message is generated.

===========================================================================

header.h:
--------
class X
{
  static int xxx;
};

int X::xxx;

one.cc:
------
#include "header.h"
X x1;

int main(void)
{
  return 0;
}

two.cc:
------
#include "header.h"
X x2;

===========================================================================

Compilation:
-----------

$> g++ one.cc two.cc
$>

Now explicitly initialize static: int X::xxx = 0;

$> g++ one.cc two.cc
ld: fatal: symbol `X::xxx ' is multiply-defined:
        (file /home/gent/tmp/ccNJ8nsh.o and file /home/gent/tmp/ccaAofN0.o);
ld: fatal: File processing errors. No output written to a.out
collect2: ld returned 1 exit status
$>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]