example: register the shared classes in both modules, as Windows requires - #114
Merged
Merged
Conversation
…ires
The implicit_linking example has never run on Windows. Its library registers
Animal, Herbivore, Cow, Carnivore and Wolf; the program creates a Wolf with
`new` and dispatches on it, and MSVC aborts:
unknown class struct Wolf
Windows keeps one `type_info` object per module, so the program's `Wolf` and
the library's `Wolf` are two different type ids, and only the library's was
ever registered. ELF and Mach-O merge the two, which is why it passes
everywhere else. `use_classes` already documents the rule - "a class must be
registered in as many translation units as necessary ... The only such case
known to the author is when using Windows DLLs" - and the example was the one
place that did not follow it.
The program now registers the library's classes as well. On ELF that is
redundant and harmless; on Windows it is what makes the example work. The page
says why, next to the example.
Verified with MSVC v18 (Ninja, Release): the test fails on develop and at
7eb56f5, the commit that introduced the example, and passes with this change.
Nothing in CI caught it because the doc examples are built only when this
project is configured as the root with tests enabled, which no CI job does -
the Boost.CI jobs build it inside the super-project, and b2's test/Jamfile
globs test_*.cpp and compile_fail_*.cpp only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQG6CbE4o2agseE7bDVzHS
|
An automated preview of the documentation is available at https://114.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-09-16 00:57:04 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #114 +/- ##
===========================================
- Coverage 93.51% 93.25% -0.26%
===========================================
Files 22 22
Lines 1695 1706 +11
Branches 504 509 +5
===========================================
+ Hits 1585 1591 +6
- Misses 66 71 +5
Partials 44 44 see 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Written by Claude Code, on behalf of @jll63.)
The
implicit_linkingexample aborts on Windows, and always has:extensions.cpp— the DLL — registersAnimal,Herbivore,Cow,CarnivoreandWolf.main.cppcreates aWolfwithnewand dispatches onit. Windows keeps one
type_infoobject per module, so the program'sWolfandthe library's
Wolfare two different type ids, and only the library's was everregistered. ELF and Mach-O merge the two, which is why it passes everywhere
else.
This is the case cpp:use_classes[] already documents:
The example was the one place that did not follow its own rule. The program now
registers the library's classes as well — redundant and harmless on ELF, and
what makes the example work on Windows.
shared_libraries.adocsays why, nextto the example, since the extra line would otherwise look like an oversight.
Not a regression
Measured with MSVC v18 BuildTools, Ninja, Release, against three trees:
7eb56f5— "support DSO/DLL on all platforms (#75)", the commit that added the exampledevelopThere is no good commit to bisect to; it has never worked on Windows.
Why CI never caught it
The doc examples are built only when this project is configured as the root
with
BOOST_OPENMETHOD_BUILD_TESTS=ON, which no CI job does: the Boost.CI jobsbuild the library inside the super-project, where that option defaults to OFF,
and b2's
test/Jamfileglobstest_*.cppandcompile_fail_*.cpponly. Soboost_openmethod-staticruns in a local root CMake build and nowhere else, onany platform.
Worth considering separately — not in this PR — whether one CI job should
configure the project as root with examples on, or this class of breakage stays
invisible.
Tests
186/186 under gcc 13.3 Release with warnings as errors; the affected test
verified directly under MSVC as above. The existing
test/implicit_shared_librariestests are unaffected — they already registertheir classes in both modules, which is why they pass on Windows today.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RQG6CbE4o2agseE7bDVzHS