Skip to content

fix(craft): delete copy ops on classes holding unique_ptr maps - #93

Merged
Cadons merged 1 commit into
mainfrom
vcpkg-fixes
Aug 30, 2026
Merged

Cadons merged 1 commit into
mainfrom
vcpkg-fixes

Conversation

@Cadons

@Cadons Cadons commented Aug 30, 2026

Copy link
Copy Markdown
Owner

MSVC's __declspec(dllexport) (DOCRAFT_LIB, active when DOCRAFT_BUILD_SHARED_LIBS is set) forces instantiation of every public member of an exported class, including implicitly-defined copy constructor/assignment. std::unordered_map<K, std::unique_ptr>'s own copy assignment isn't SFINAE-disabled based on value_type (a pre-C++20 container quirk), so the implicit copy ops on DocraftLoomTagHandlerRegistry and DocraftCraftLanguageParser were never deleted at the type level -- only broken when actually instantiated. GCC/Clang's static-lib builds never instantiate unused implicit members, so this only surfaces on a Windows/MSVC shared-lib build (error C2679 trying to copy-assign the unique_ptr-valued map).

Neither class is ever copied (registry is a singleton; the parser is always used as a local) -- explicitly deleting copy ctor/assignment on both fixes the DLL export instantiation without changing any call site.

Claude-Session: https://claude.ai/code/session_015RjTSLobQWMZq8DcFyDZoG

MSVC's __declspec(dllexport) (DOCRAFT_LIB, active when
DOCRAFT_BUILD_SHARED_LIBS is set) forces instantiation of every public
member of an exported class, including implicitly-defined copy
constructor/assignment. std::unordered_map<K, std::unique_ptr<V>>'s
own copy assignment isn't SFINAE-disabled based on value_type (a
pre-C++20 container quirk), so the implicit copy ops on
DocraftLoomTagHandlerRegistry and DocraftCraftLanguageParser were
never deleted at the type level -- only broken when actually
instantiated. GCC/Clang's static-lib builds never instantiate unused
implicit members, so this only surfaces on a Windows/MSVC shared-lib
build (error C2679 trying to copy-assign the unique_ptr-valued map).

Neither class is ever copied (registry is a singleton; the parser is
always used as a local) -- explicitly deleting copy ctor/assignment on
both fixes the DLL export instantiation without changing any call
site.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RjTSLobQWMZq8DcFyDZoG
@Cadons
Cadons merged commit 530ceae into main Aug 30, 2026
7 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant