0017-c++-abi-break.diff 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822
  2. Author: Jonathan Wakely <[email protected]>
  3. Date: Wed Oct 31 13:03:25 2018 +0000
  4. PR libstdc++/87822 fix layout change for nested std::pair
  5. The introduction of the empty __pair_base base class for PR 86751
  6. changed the layout of std::pair<std::pair<...>, ...>. The outer pair and
  7. its first member both have a base class of the same type, which cannot
  8. exist at the same address. This causes the first member to be at a
  9. non-zero offset.
  10. The solution is to make the base class depend on the template
  11. parameters, so that each pair type has a different base class type,
  12. which allows the base classes of the outer pair and its first member to
  13. have the same address.
  14. PR libstdc++/87822
  15. * include/bits/stl_pair.h (__pair_base): Change to class template.
  16. (pair): Make base class type depend on template parameters.
  17. diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
  18. index a30b630b4fd..5a4823ab018 100644
  19. --- a/libstdc++-v3/include/bits/stl_pair.h
  20. +++ b/libstdc++-v3/include/bits/stl_pair.h
  21. @@ -183,7 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  22. };
  23. #endif // C++11
  24. - class __pair_base
  25. + template<typename _U1, typename _U2> class __pair_base
  26. {
  27. #if __cplusplus >= 201103L
  28. template<typename _T1, typename _T2> friend struct pair;
  29. @@ -202,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  30. */
  31. template<typename _T1, typename _T2>
  32. struct pair
  33. - : private __pair_base
  34. + : private __pair_base<_T1, _T2>
  35. {
  36. typedef _T1 first_type; /// @c first_type is the first bound type
  37. typedef _T2 second_type; /// @c second_type is the second bound type