Bug 89942 - std::function __is_location_invariant breaks ABI compatibility
Summary: std::function __is_location_invariant breaks ABI compatibility
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-03 07:59 UTC by Kan Liu
Modified: 2019-04-03 08:31 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
possible fix (139 bytes, text/plain)
2019-04-03 07:59 UTC, Kan Liu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kan Liu 2019-04-03 07:59:37 UTC
Created attachment 46079 [details]
possible fix

in gcc 5.4.0

 template<typename _Tp>
    struct __is_location_invariant
    : is_trivially_copyable<_Tp>::type
    { };

__is_location_invariant is evaluated to be true for the closure type (lambda expression)

in gcc 4.9.2

  template<typename _Tp>
    struct __is_location_invariant
    : integral_constant<bool, (is_pointer<_Tp>::value
                               || is_member_pointer<_Tp>::value)>
    { };

which is evaluated to be false.

This may break ABI compatibility when pass function object between libs compiled by 4.9.2 / 5.4.0 gcc.

The attachment is a possible fix.
Comment 1 Jonathan Wakely 2019-04-03 08:31:11 UTC
(In reply to Kan Liu from comment #0)
> This may break ABI compatibility when pass function object between libs
> compiled by 4.9.2 / 5.4.0 gcc.

That's not supported, because the C++11 ABI didn't stabilise until GCC 5.1.0, see 
https://stackoverflow.com/questions/46746878/is-it-safe-to-link-c17-c14-and-c11-objects/49119902#49119902 for a longer explanation.

The attached patch doesn't solve the problem, it just moves it. Now you'd have ABI incompatibility between GCC 5.x and GCC 5.x, which is even worse.