From 9e3b68c55b52c771892fa66e52578e5bb342415a Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 1 Dec 2026 04:38:12 +0800 Subject: [PATCH 1/3] fix(e2e): define session's default constructor out of line session() = default in the interface instantiates, in every importer under MSVC's STL, the destructor of unique_ptr with state incomplete (sizeof an incomplete type): a program could not default-construct a session at all. Declared in the interface, defined in e2e.cpp; a case constructs one. --- lib/src/e2e.cpp | 6 +++++- lib/src/e2e.cppm | 2 +- lib/tests/companions.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) 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..50b9e4f 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())); From 511803ac2ea8f75740a8d20c4066332802653242 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 1 Dec 2026 04:46:54 +0800 Subject: [PATCH 2/3] test(e2e): as .clang-format writes it --- lib/tests/companions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tests/companions.cpp b/lib/tests/companions.cpp index 50b9e4f..efe7dcb 100644 --- a/lib/tests/companions.cpp +++ b/lib/tests/companions.cpp @@ -329,7 +329,7 @@ int main(int argc, char** argv) { 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 + 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()); From 43713a0ed2ea027a8fe19b906ef4736119ba4be1 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 1 Dec 2026 04:49:36 +0800 Subject: [PATCH 3/3] changelog: e2e::session's default constructor, for 0.11.4 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) 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`).