diff --git a/CHANGELOG.md b/CHANGELOG.md index e14e535..3c2f5ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ starts. The doctest adapter's own test checks it under `mcpp test`. - The conformance suite holds an implementation below level 3 that expresses `expected to fail` to its `xfail`; the doctest fixture expresses it. +- `e2e::session` can be default-constructed. Its default constructor was defaulted in the interface + unit, which made every importer that default-constructs a session instantiate, under MSVC's + STL, the destructor of its `unique_ptr` with `state` incomplete: a compile error. It is + declared in the interface and defined in `e2e.cpp`, beside the destructor and the move + constructor; a case constructs one and checks it holds nothing. - CI builds and tests with mcpp 2026.11.22.1 and xlings 2026.11.21.1, the xlings that release bundles (`.github/versions.env`). diff --git a/lib/src/e2e.cpp b/lib/src/e2e.cpp index ffb69ba..728821d 100644 --- a/lib/src/e2e.cpp +++ b/lib/src/e2e.cpp @@ -497,7 +497,11 @@ session session::start(command c) { return s; } -session::session(session&&) noexcept = default; +// Defined here, not defaulted in the interface: the default constructor of a +// class holding unique_ptr with state incomplete instantiates the +// pointer's destructor in the importer under MSVC's STL (sizeof an incomplete +// type), so a program could not default-construct a session at all. +session::session() = default; session& session::operator=(session&&) noexcept = default; session::~session() { if (s_ && s_->started && s_->proc.valid()) { diff --git a/lib/src/e2e.cppm b/lib/src/e2e.cppm index 9f0eead..4fb0698 100644 --- a/lib/src/e2e.cppm +++ b/lib/src/e2e.cppm @@ -122,7 +122,7 @@ public: // whose `started()` is false and whose transcript says why. static session start(command c); - session() = default; + session(); session(session&&) noexcept; session& operator=(session&&) noexcept; session(const session&) = delete; diff --git a/lib/tests/companions.cpp b/lib/tests/companions.cpp index 4e65096..efe7dcb 100644 --- a/lib/tests/companions.cpp +++ b/lib/tests/companions.cpp @@ -328,6 +328,12 @@ int main(int argc, char** argv) { expect(eq(r.status, 7)); expect(contains(s.transcript(), "[sent] one")); }; + "a session default-constructed holds nothing"_test[kind::e2e] = [] { + e2e::session s; // an importer could not even write this line under MSVC's STL + expect(!s.started()); + expect(!s.timed_out()); + expect(s.pending().empty()); + }; "a session whose program ended says so"_test[kind::e2e] = [] { auto self = self_command(); expect(fatal(!self.empty()));