preprocessor/10434: Duplicate symbol __tcf_0 when using precompiled headers
Fri Apr 18 18:16:00 GMT 2003

>Number:         10434
>Category:       preprocessor
>Synopsis:       Duplicate symbol __tcf_0 when using precompiled headers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 18 18:16:00 UTC 2003
>Release:        gcc version 3.4 20030417 (experimental)
Mandrake linux 7.2 - kernel=2.4.18-6mdkenterprise #1 SMP
A header which contains an inlined static method with a static local variable requiring a destructor included in a precompiled header will cause the symbol __tcf_0 to be generated in the resulting code.  If a source file that includes the precompiled header also has a function static variable requiring a destructor, it will ALSO generate the symbol __tcf_0, and the assembler will fail since the symbol exists twice.

To generate the pch:

$ g++ -x c++-header pchtest.h

To get the error (note: If -save-temps is used on this command line, the problem goes away - it correctly generates __tcf_0 and __tcf_1.  -save-temps may not be loading the precompiled version of the header):

$ g++ -v pchtest.cpp
Reading specs from /usr/unstable/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --prefix=/usr/unstable
Thread model: posix
gcc version 3.4 20030417 (experimental)
 /usr/unstable/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -quiet -v -D_GNU_SOURCE pchtest.cpp -quiet -dumpbase pchtest.cpp -auxbase pchtest -version -o /home/ogre/tmp/cccm6fmX.s
ignoring nonexistent directory "/usr/unstable/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
GNU C++ version 3.4 20030417 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20030417 (experimental).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128638
 as -V -Qy -o /home/ogre/tmp/cckPnPbL.o /home/ogre/tmp/cccm6fmX.s
GNU assembler version (i586-mandrake-linux-gnu) using BFD version 20011121
/home/ogre/tmp/cccm6fmX.s: Assembler messages:
/home/ogre/tmp/cccm6fmX.s:91: Error: symbol `__tcf_0' is already defined
Follow commands above using these files.  pchtest.ii is output from g++ -v -save-temps -x c++-header pchtest.h.

begin 644 staticpchbug.tar.gz
start_cleanup_fn in gcc/cp/decl.c has a variable:

static int counter = 0;

That will be 0 both when the pch is built and when it is included.  If the function is called both times, it will generate two symbols both named __tcf_0 using that variable.  It seems like the value of that variable needs to be saved in the pch, but doing that is beyond my knowledge of how things work.


More information about the Gcc-bugs mailing list