[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

Jonathan Wakely  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
  Known to work||6.4.0, 7.3.0, 8.2.0
 Resolution|--- |FIXED
  Known to fail||6.4.1, 7.3.1, 8.2.1, 9.0

--- Comment #14 from Jonathan Wakely  ---
.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #13 from Jonathan Wakely  ---
Created attachment 44936
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44936=edit
Patch for GCC 6.5

Fixed in the gcc-7 and gcc-8 branches.

This will not be fixed on gcc-6-branch, but for anybody who wants to apply it
locally, the patch for GCC 6.5 is attached, and reproduced here:

--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -187,7 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 #endif // C++11

-  class __pair_base
+  template class __pair_base
   {
 #if __cplusplus >= 201103L
 template friend struct pair;
@@ -206,7 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
   template
 struct pair
-: private __pair_base
+: private __pair_base<_T1, _T2>
 {
   typedef _T1 first_type;/// @c first_type is the first bound type
   typedef _T2 second_type;   /// @c second_type is the second bound type

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #12 from Jonathan Wakely  ---
Author: redi
Date: Wed Oct 31 13:16:10 2018
New Revision: 265683

URL: https://gcc.gnu.org/viewcvs?rev=265683=gcc=rev
Log:
PR libstdc++/87822 fix layout change for nested std::pair

The introduction of the empty __pair_base base class for PR 86751
changed the layout of std::pair, ...>. The outer pair and
its first member both have a base class of the same type, which cannot
exist at the same address. This causes the first member to be at a
non-zero offset.

The solution is to make the base class depend on the template
parameters, so that each pair type has a different base class type,
which allows the base classes of the outer pair and its first member to
have the same address.

PR libstdc++/87822
* include/bits/stl_pair.h (__pair_base): Change to class template.
(pair): Make base class type depend on template parameters.
* testsuite/20_util/pair/87822.cc: New test.

Added:
branches/gcc-7-branch/libstdc++-v3/testsuite/20_util/pair/87822.cc
Modified:
branches/gcc-7-branch/libstdc++-v3/ChangeLog
branches/gcc-7-branch/libstdc++-v3/include/bits/stl_pair.h

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #11 from Jonathan Wakely  ---
Author: redi
Date: Wed Oct 31 13:03:25 2018
New Revision: 265681

URL: https://gcc.gnu.org/viewcvs?rev=265681=gcc=rev
Log:
PR libstdc++/87822 fix layout change for nested std::pair

The introduction of the empty __pair_base base class for PR 86751
changed the layout of std::pair, ...>. The outer pair and
its first member both have a base class of the same type, which cannot
exist at the same address. This causes the first member to be at a
non-zero offset.

The solution is to make the base class depend on the template
parameters, so that each pair type has a different base class type,
which allows the base classes of the outer pair and its first member to
have the same address.

PR libstdc++/87822
* include/bits/stl_pair.h (__pair_base): Change to class template.
(pair): Make base class type depend on template parameters.
* testsuite/20_util/pair/87822.cc: New test.

Added:
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/pair/87822.cc
Modified:
branches/gcc-8-branch/libstdc++-v3/ChangeLog
branches/gcc-8-branch/libstdc++-v3/include/bits/stl_pair.h

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread romain.geissler at amadeus dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #10 from Romain Geissler  ---
Thanks for the quick patch !

If no commit is planned in the branch 6, I am going to apply this patch on top
myself. I hope people do read the release notes to figure out about this
potential ABI breaking.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #9 from Jonathan Wakely  ---
Author: redi
Date: Wed Oct 31 12:29:02 2018
New Revision: 265678

URL: https://gcc.gnu.org/viewcvs?rev=265678=gcc=rev
Log:
PR libstdc++/87822 fix layout change for nested std::pair

The introduction of the empty __pair_base base class for PR 86751
changed the layout of std::pair, ...>. The outer pair and
its first member both have a base class of the same type, which cannot
exist at the same address. This causes the first member to be at a
non-zero offset.

The solution is to make the base class depend on the template
parameters, so that each pair type has a different base class type,
which allows the base classes of the outer pair and its first member to
have the same address.

PR libstdc++/87822
* include/bits/stl_pair.h (__pair_base): Change to class template.
(pair): Make base class type depend on template parameters.
* testsuite/20_util/pair/87822.cc: New test.

Added:
trunk/libstdc++-v3/testsuite/20_util/pair/87822.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/stl_pair.h

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread rguenther at suse dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #8 from rguenther at suse dot de  ---
On Wed, 31 Oct 2018, redi at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822
> 
> --- Comment #7 from Jonathan Wakely  ---
> (In reply to Richard Biener from comment #5)
> > Unfortunate :/  Can you add a 6.5 specific note to 6.5/changes.html?
> 
> Will do.
> 
> I think it would also be good to commit the fix to the gcc-6-branch, even if
> it's closed, so it can be picked up from there if needed.

Hmm.  I think it may be better to provide the fix as patch, referenced
from the changes.html note?

> Do we even want to consider a 6.6 release, or just officially bless a 6.5.1
> snapshot post-fix?

Neither of that (there are no further snapshots from the branch anyways).
Since 6.5 isn't supported anymore I'd rather point people to 7.x.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #7 from Jonathan Wakely  ---
(In reply to Richard Biener from comment #5)
> Unfortunate :/  Can you add a 6.5 specific note to 6.5/changes.html?

Will do.

I think it would also be good to commit the fix to the gcc-6-branch, even if
it's closed, so it can be picked up from there if needed.

Do we even want to consider a 6.6 release, or just officially bless a 6.5.1
snapshot post-fix?

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

Jonathan Wakely  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org

--- Comment #6 from Jonathan Wakely  ---
It only affects std::pair, z> (for any x, y, z) i.e. when the
first member of the pair is also a pair.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

Richard Biener  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Richard Biener  ---
(In reply to Jonathan Wakely from comment #4)
> The fix isn't in any other releases yet, only 6.5

Unfortunate :/  Can you add a 6.5 specific note to 6.5/changes.html?

How pervasive is this issue?

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #4 from Jonathan Wakely  ---
The fix isn't in any other releases yet, only 6.5

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

--- Comment #3 from Jonathan Wakely  ---
(In reply to Romain Geissler from comment #0)
> (introduce a new
> tagged std::pair type and provide dual abi ?).

No, no, no! Anything but that.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-10-31
 Ever confirmed|0   |1

--- Comment #2 from Jonathan Wakely  ---
Argh, dammit. Yes, it should have been a template.

[Bug libstdc++/87822] [6/7/8/9 Regression] Binary incompatibility in std::pair introduced by PR 86751

2018-10-31 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87822

Richard Biener  changed:

   What|Removed |Added

   Keywords||ABI
 CC||rguenth at gcc dot gnu.org
 Blocks||86751
   Target Milestone|--- |7.4
Summary|[regression 6/7/8/9] Binary |[6/7/8/9 Regression] Binary
   |incompatibility in  |incompatibility in
   |std::pair introduced by PR  |std::pair introduced by PR
   |86751   |86751


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86751
[Bug 86751] [6/7/8 Regression] Ambiguous operator= overload for std::pair