Bug 15412 - [3.4/4.0 Regression] _GLIBCXX_ symbols symbols defined and used in different namespaces
Summary: [3.4/4.0 Regression] _GLIBCXX_ symbols symbols defined and used in different ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.0
: P1 normal
Target Milestone: 3.4.1
Assignee: Benjamin Kosnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-13 02:14 UTC by Wu Yongwei
Modified: 2004-10-30 21:11 UTC (History)
3 users (show)

See Also:
Host: mingw32
Target: mingw32
Build:
Known to work:
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-05-13 03:04:14


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wu Yongwei 2004-05-13 02:14:22 UTC
This short program cannot build:

------------------------------------------------------------------
#include <memory>
#include <ext/pool_allocator.h>

int main()
{
   void* ptr = __gnu_cxx::__pool_alloc<true,0>::allocate(10);
   __gnu_cxx::__pool_alloc<true,0>::deallocate(ptr, 10);
}
------------------------------------------------------------------

A number of link errors will appear:

d:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.0/../../../libstdc++.a(allocator.o)
(.text$_ZN9__gnu_cxx12__pool_allocILb1ELi0EE5_LockC1Ev+0x31):allocator.cc: 
undefined reference to `__gnu_cxx::_GLIBCXX_mutex_address'
d:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.0/../../../libstdc++.a(allocator.o)
(.text$_ZN9__gnu_cxx12__pool_allocILb1ELi0EE5_LockC1Ev+0x4c):allocator.cc: 
undefined reference to `__gnu_cxx::_GLIBCXX_mutex'
d:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.0/../../../libstdc++.a(allocator.o)
(.text$_ZN9__gnu_cxx12__pool_allocILb1ELi0EE5_LockC1Ev+0x84):allocator.cc: 
undefined reference to `__gnu_cxx::_GLIBCXX_once'
d:/mingw-gcc3.4/bin/../lib/gcc/mingw32/3.4.0/../../../libstdc++.a(allocator.o)
(.text$_ZN9__gnu_cxx12__pool_allocILb1ELi0EE5_LockC1Ev+0x89):allocator.cc: 
undefined reference to `__gnu_cxx::_GLIBCXX_mutex_init()'
...

The cause is that libstdc++-v3/include/bits/stl_threads.h references these 
symbols in namespace `__gnu_cxx', and libstdc++-v3/src/globals_io.cc defines 
them in namespace `__gnu_internal'.  It seems to affect all platforms.
Comment 1 Andrew Pinski 2004-05-13 02:56:17 UTC
Note the template argument for __pool_alloc has changed on the mainline.

And no this does effect all targets, it only not define __GTHREAD_MUTEX_INIT but 
__GTHREAD_MUTEX_INIT_FUNCTION in gthr-*.h

So it is not including them for some reason.
Comment 2 Andrew Pinski 2004-05-13 03:04:13 UTC
Confirmed.
Was broken by:
2003-10-21  Benjamin Kosnik  <bkoz@redhat.com>

        * include/ext/mt_allocator.h: Change include to gthr.h.
        * include/ext/rope: Same. Add _Refcount_base definitions.
        * include/ext/pool_allocator.h: Adjust namespaces.
        * include/bits/stl_threads.h (_Refcount_base): Move.
        Put remaining into namespace __gnu_cxx.
Comment 3 GCC Commits 2004-05-13 14:54:34 UTC
Subject: Bug 15412

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bkoz@gcc.gnu.org	2004-05-13 14:54:25

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: stl_threads.h 

Log message:
	2004-05-13  Benjamin Kosnik  <bkoz@redhat.com>
	
	PR libstdc++/15412
	* include/bits/stl_threads.h (_GLIBCXX_mutex): Move to namespace
	__gnu_internal.
	(_GLIBCXX_mutex_address): Same.
	(_GLIBCXX_once): Same.
	(_GLIBCXX_mutex_init): Same.
	(_GLIBCXX_mutex_address_init): Same.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2469&r2=1.2470
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_threads.h.diff?cvsroot=gcc&r1=1.21&r2=1.22

Comment 4 Benjamin Kosnik 2004-05-13 14:58:35 UTC
This is now fixed.
Comment 5 GCC Commits 2004-05-13 15:26:03 UTC
Subject: Bug 15412

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	bkoz@gcc.gnu.org	2004-05-13 15:25:54

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: stl_threads.h 

Log message:
	2004-05-13  Benjamin Kosnik  <bkoz@redhat.com>
	
	PR libstdc++/15412
	* include/bits/stl_threads.h (_GLIBCXX_mutex): Move to namespace
	__gnu_internal.
	(_GLIBCXX_mutex_address): Same.
	(_GLIBCXX_once): Same.
	(_GLIBCXX_mutex_init): Same.
	(_GLIBCXX_mutex_address_init): Same.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.97&r2=1.2224.2.98
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_threads.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.20.10.1&r2=1.20.10.2

Comment 6 Benjamin Kosnik 2004-05-18 01:19:43 UTC
If, for some strange reason, this is not fixed, please re-open.