Bug 170875 - Cannot compile JavaScriptCore/runtime/VMTraps.cpp on FreeBSD because std::pair has a non-trivial copy constructor
Summary: Cannot compile JavaScriptCore/runtime/VMTraps.cpp on FreeBSD because std::pai...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: JF Bastien
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-15 08:26 PDT by Ting-Wei Lan
Modified: 2017-04-19 11:25 PDT (History)
9 users (show)

See Also:


Attachments
patch (3.88 KB, patch)
2017-04-19 09:54 PDT, JF Bastien
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2017-04-15 08:26:25 PDT
In JavaScriptCore/runtime/VMTraps.cpp, function findActiveVMAndStackBounds returns a WTF::Expected<std::pair<JSC::VM*, WTF::StackBounds>, JSC::VMTraps::Error>. The parent class of this type is WTF::ExpectedDetail::ConstexprBase<std::pair<JSC::VM*, WTF::StackBounds>, JSC::VMTraps::Error>.

WTF::ExpectedDetail::ConstexprBase doesn't have a user-defined copy constructor, and its implicitly-defined copy constructor is deleted because the default std::pair implementation on FreeBSD has a non-trivial copy constructor. /usr/include/c++/v1/__config says _LIBCPP_TRIVIAL_PAIR_COPY_CTOR is disabled in order to keep ABI compatibility: https://svnweb.freebsd.org/changeset/base/261801.


Error messages showed by the compiler (clang 3.8):

/path/to/WebKit/Source/JavaScriptCore/runtime/VMTraps.cpp:96:9: error: returning object of type 'Expected<std::pair<VM *, StackBounds>, VMTraps::Error>' invokes deleted constructor
        return makeUnexpected(VMTraps::Error::LockUnavailable);
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../Source/WTF/wtf/Expected.h:262:5: note: explicitly defaulted function was implicitly deleted here
    Expected(const Expected&) = default;
    ^
../../Source/WTF/wtf/Expected.h:248:18: note: copy constructor of 'Expected<std::__1::pair<JSC::VM *, WTF::StackBounds>, JSC::VMTraps::Error>' is implicitly deleted because base class 'ExpectedDetail::BaseSelect<pair<VM *, StackBounds>, Error>' (aka 'WTF::ExpectedDetail::ConstexprBase<std::__1::pair<JSC::VM *, WTF::StackBounds>, JSC::VMTraps::Error>') has a deleted copy constructor
class Expected : private ExpectedDetail::BaseSelect<T, E> {
                 ^
../../Source/WTF/wtf/Expected.h:145:44: note: copy constructor of 'ConstexprBase<std::__1::pair<JSC::VM *, WTF::StackBounds>, JSC::VMTraps::Error>' is implicitly deleted because field 's' has a deleted copy constructor
    ConstexprStorage<ValueType, ErrorType> s;
                                           ^
../../Source/WTF/wtf/Expected.h:87:15: note: copy constructor of 'ConstexprStorage<std::__1::pair<JSC::VM *, WTF::StackBounds>, JSC::VMTraps::Error>' is implicitly deleted because variant field 'val' has a non-trivial copy constructor
    ValueType val;
              ^
Comment 1 JF Bastien 2017-04-19 01:25:59 PDT
It is surprising to see the constexpr version being instantiated here.
Comment 2 Ting-Wei Lan 2017-04-19 08:27:47 PDT
(In reply to JF Bastien from comment #1)
> It is surprising to see the constexpr version being instantiated here.

JSC::VM*, WTF::StackBounds, JSC::VMTraps::Error are all trivially destructible, so WTF::ExpectedDetail::BaseSelect is WTF::ExpectedDetail::ConstexprBase here.
Comment 3 JF Bastien 2017-04-19 09:54:47 PDT
Created attachment 307486 [details]
patch

(In reply to Ting-Wei Lan from comment #2)
> (In reply to JF Bastien from comment #1)
> > It is surprising to see the constexpr version being instantiated here.
> 
> JSC::VM*, WTF::StackBounds, JSC::VMTraps::Error are all trivially
> destructible, so WTF::ExpectedDetail::BaseSelect is
> WTF::ExpectedDetail::ConstexprBase here.

Derp, right you are!

Here's a patch that works around the issue.
Comment 4 Mark Lam 2017-04-19 09:56:53 PDT
Comment on attachment 307486 [details]
patch

r=me if EWS bots build and are happy.
Comment 5 JF Bastien 2017-04-19 10:40:40 PDT
Comment on attachment 307486 [details]
patch

Tests are broken for unrelated reason. Fetch or somesuch.

cq+
Comment 6 WebKit Commit Bot 2017-04-19 11:25:46 PDT
Comment on attachment 307486 [details]
patch

Clearing flags on attachment: 307486

Committed r215522: <http://trac.webkit.org/changeset/215522>
Comment 7 WebKit Commit Bot 2017-04-19 11:25:48 PDT
All reviewed patches have been landed.  Closing bug.