What are the implications of using _GLIBCXX_CXX11_ABI for using pre-5.1 C ++ ABI with C ++ 11/14 capabilities?

From the manual:

In GCC 5.1, libstdC ++ introduced the new ABI library, which includes new implementations of std :: string and std :: list. These changes were necessary to comply with the 2011 C ++ standard, which prohibits Copy-On-Write strings and requires lists to track their size.

The _GLIBCXX_USE_CXX11_ABI macro can be used to control library headers using the old or new ABI, regardless of which "-std" is used.

I would like to know what would be the consequences of using this โ€œABI compatibilityโ€? I suppose that performance during operations with small strings will be affected (negatively), and this list access depends on O (1) (C11 ABI) to O (N) (ABI compatibility).

  • Is my guess right and can anyone work out?
  • Are there any other consequences that I missed? What about the atomatics and concurrency functions? Any impact?
+6
source share
1 answer

The manual itself answers your first question:

... the choice of ABI to use does not depend on the -std parameter used to compile your code ... This ensures that -std does not change the ABI, so it is easy to connect the C ++ 03 and C ++ 11 code together.

Regarding the second question, I'm afraid this is hard to generalize because it depends on how your code uses the standard library. Does he copy a lot of lines? How often is the list size requested? Is the code multi-threaded?

Although atomicity and concurrency were introduced in the C ++ 11 standard, I would suggest that the stdlib ++ copy-on-write mechanism already used variation anyway. These implementations are usually thread safe.

Perhaps one thing you didn't talk about directly is the effect on other std components that depend on these behaviors such as list::splice

+1
source

All Articles