This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Remove _Safe_container _IsCxx11AllocatorAware template parameter
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 May 2017 11:38:46 +0100
- Subject: Re: Remove _Safe_container _IsCxx11AllocatorAware template parameter
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 735ED4E4D2
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 735ED4E4D2
- References: <1704fc02-f876-1fc5-070f-0decc2aa41fe@gmail.com>
On 11/05/17 22:03 +0200, François Dumont wrote:
Hi
_Safe_container _IsCxx11AllocatorAware template allocator is only
used if C++11 Abi is not used so I simplified it.
* include/debug/safe_container.h [_GLIBCXX_USE_CXX11_ABI]
(_Safe_container<>): Remove _IsCxx11AllocatorAware template parameter.
* include/debug/string: Adapt.
Tested under Linux x86_64 with debug mode and active C++11 Abi.
Wait, doesn't this mean that debug containers have a different base
class depending on which ABI is active in the translation unit? That
is a One-Definition Rule violation when you link together objects
compiled with different values of _GLIBCXX_USE_CXX11_ABI, which is
supposed to work. I went to enormous effort to ensure it works.
François
diff --git a/libstdc++-v3/include/debug/safe_container.h b/libstdc++-v3/include/debug/safe_container.h
index 3d44c15..e985c2a 100644
--- a/libstdc++-v3/include/debug/safe_container.h
+++ b/libstdc++-v3/include/debug/safe_container.h
@@ -36,8 +36,12 @@ namespace __gnu_debug
/// Safe class dealing with some allocator dependent operations.
template<typename _SafeContainer,
typename _Alloc,
- template<typename> class _SafeBase,
- bool _IsCxx11AllocatorAware = true>
+ template<typename> class _SafeBase
+#if _GLIBCXX_USE_CXX11_ABI
+ >
+#else
+ , bool _IsCxx11AllocatorAware = true>
+#endif
class _Safe_container
In any case, I don't think this is simpler, there are more lines of
code, and the preprocessor condition makes it harder to read and
harder to reason about.
: public _SafeBase<_SafeContainer>
{
@@ -82,8 +86,10 @@ namespace __gnu_debug
{
__glibcxx_check_self_move_assign(__x);
+# if !_GLIBCXX_USE_CXX11_ABI
if (_IsCxx11AllocatorAware)
{
+# endif
This is fairly pointless. Again it makes the code a bit harder to
read, and since it's a compile-time constant the condition will be
optimised away completely.