[patch] Use abi_tag attribute on std::list

Jonathan Wakely jwakely@redhat.com
Fri Oct 3 13:04:00 GMT 2014


This is the patch I intend to commit to make std::list::size() O(1) as
required by C++11.

This is an ABI change, so std::list will get tagged with
abi_tag("cxx11") so that it mangles differently.

I took a different approach to the way O(1) size() was implemented
(and then reverted) for GCC 4.7.0, because I didn't like updating the
size when node are (de)allocated. Instead this patch adjusts the size
when nodes are added or removed from the list, rather then when
they're allocated.

Instead of littering the code with #if checks I added new
_M_xxx_size() members that can be called unconditionally when
modifying the list, but they do nothing when there's no size member.
This means there's only a single #if condition added to std::list by
this patch.

There will be another patch coming soon to add C++11 allocator support
to std::list, and another to add a non-COW std::string using abi_tag.

I don't yet know what we should do about the
--enable-symvers=gnu-versioned-namespace configuration, maybe we
should move the soname for that option to libstdc++.so.8 and have
_GLIBCXX_USE_CXX11_ABI=1 and _GLIBCXX_DEFAULT_ABI_TAG= set always,
so that the versioned-namespace configuration always gets the new ABI
and doesn't need to use the tag (because using that configuration
already implies you're not interested in ABI compatibility). I'd
prefer not to have versioned-namespace-with-new-abi and
versioned-namespace-without-new-abi configurations, given that we don't
know if anyone's even using versioned namespaces for anything serious.

Tested x86_64-linux, with --disable-libstdcxx-cxx11-abi and without.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 15447 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141003/adc49edb/attachment.bin>


More information about the Gcc-patches mailing list