Skip to content

fix: avoid per-instantiation vtable issues with MinGW GCC#1290

Open
DiamonDinoia wants to merge 1 commit intoxtensor-stack:masterfrom
DiamonDinoia:fix/mingw-doctest-vtable
Open

fix: avoid per-instantiation vtable issues with MinGW GCC#1290
DiamonDinoia wants to merge 1 commit intoxtensor-stack:masterfrom
DiamonDinoia:fix/mingw-doctest-vtable

Conversation

@DiamonDinoia
Copy link
Copy Markdown
Contributor

Replace INFO() macro calls with concrete StringContextScope class to work around MinGW GCC generating a unique vtable per template instantiation. INFO() creates ContextScope which triggers this issue; the concrete class has a single vtable definition shared across all instantiations.

  • Add StringContextScope struct inheriting from doctest::detail::ContextScopeBase
  • Add make_context_info() helper to create context without template lambdas
  • Update CHECK_BATCH_EQ, CHECK_SCALAR_EQ, CHECK_VECTOR_EQ macros to use new helper

Replace INFO() macro calls with concrete StringContextScope class to work
around MinGW GCC generating a unique vtable per template instantiation.
INFO() creates ContextScope<Lambda> which triggers this issue; the concrete
class has a single vtable definition shared across all instantiations.

- Add StringContextScope struct inheriting from doctest::detail::ContextScopeBase
- Add make_context_info() helper to create context without template lambdas
- Update CHECK_BATCH_EQ, CHECK_SCALAR_EQ, CHECK_VECTOR_EQ macros to use new helper
#define CHECK_BATCH_EQ(b1, b2) \
do \
{ \
auto _ctx1 = ::detail::make_context_info(#b1, b1); \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a small comment here and below to explain why we're doing something smart :-)

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.

2 participants