Skip to content

Explicitly default copying for polymorphic option types - #162

Open
trestoncuzzort wants to merge 1 commit into
boostorg:developfrom
trestoncuzzort:fix-explicit-polymorphic-copy
Open

trestoncuzzort wants to merge 1 commit into
boostorg:developfrom
trestoncuzzort:fix-explicit-polymorphic-copy

Conversation

@trestoncuzzort

Copy link
Copy Markdown

Fixes #146 and #147.

With -Werror=deprecated-copy-with-dtor, copying a variables_map, returning one by value, or creating a typed option can fail to compile. The implicit copies are deprecated because the relevant polymorphic classes declare destructors.

Explicitly default copy construction and assignment in abstract_variables_map and the exception classes that declare destructors. Retain the destructors and existing memberwise copy behavior, including the non-owning next-map link and copy fallback for exception rvalues.

Add one regression through both static and shared test targets. On Clang versions supporting the diagnostic, it promotes the warning to an error. Runtime checks cover exception messages, context, kinds, alternatives and config tokens; map fallback links, required options, final values, composing vectors, notifier lifetime, and copy/move destinations.

Validation:

  • Pristine GCC 16/C++11 and Clang 23/C++17 full suites each pass 28 checks. Fixed suites each pass 30, including both new targets.
  • The same runtime assertions pass with the pristine GCC library. With pristine headers, the Clang regression fails with 25 deprecated-copy diagnostics; fixed headers compile cleanly.
  • Platform checks pass with new headers linked against pristine and rebuilt static/shared libraries: Linux GCC 11, Linux Clang ASan/UBSan, and Windows MSVC, plus macOS Clang. The macOS follow-up renames the validation script to avoid shadowing Python’s standard-library copy module; source and assertions are unchanged.
  • The regression passes with the full library instrumented by Clang ASan/UBSan. Both new B2 regression binaries pass explicit Valgrind checks with zero errors or leaks.
  • Seven offline dawnr kernels verify the finite lookup-priority contract used by the regression and refute a dropped-chain control. This checks the contract model, not C++ copy declarations or the compiled library.

Implemented and tested with Codex assistance; every changed line was self-reviewed.

Retain existing destructors and copy behavior while avoiding deprecated implicit-copy diagnostics for exception classes and abstract_variables_map. Test exception payloads and variables-map copy/move destinations through static and shared builds.

Fixes boostorg#146. Fixes boostorg#147.

Generated-by: Codex
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.

variable_map implicit copy/move constructors

1 participant