fix: work around clang 20/21 + libc++ compile failure in TEMPLATE_PRODUCT_TEST_CASE with differing arities#3173
Conversation
…DUCT_TEST_CASE with differing arities Fixes catchorg#3115
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #3173 +/- ##
=======================================
Coverage 91.09% 91.09%
=======================================
Files 204 204
Lines 8922 8922
=======================================
Hits 8127 8127
Misses 795 795 🚀 New features to boost your workflow:
|
rajpratham1
left a comment
There was a problem hiding this comment.
Looks good to me. This is a minimal, targeted workaround for the Clang 20/21 template-template parameter issue, and it doesn't change public behavior. The added comment explains why the separate get_template_wrapper exists, which improves maintainability. One small suggestion would be to reference the relevant LLVM/Clang issue (or include the compiler error) in the comment so it's easier to remove the workaround once the upstream bug is fixed.
|
Thanks for the review. Good suggestion - added the reference in a0c7a39: the workaround comment now points at llvm/llvm-project#130778 (the Clang 20 'conflicting deduction' regression; its duplicate #138078 shows the exact diagnostic) and notes get_template_wrapper can be removed once Clang 21 is no longer supported. |
Description
Restructure the
get_wrapperoverload set emitted byINTERNAL_CATCH_TYPE_GENin src/catch2/internal/catch_preprocessor.hpp so clang 20/21 no longer sees a conflicting deduction between the explicitly-specified template-template argument and the deduced parameter pack. Concretely, avoid mixing an explicitly-specifiedtemplate <typename...> classargument with deduction against the same overload name: split the plain-type (TypeList<Ts...>) and template-template (TemplateTypeList<Cs...>) resolution into distinct helper names or a tag-dispatched trait, keeping the existingpriority_tagranking and identical resulting types soINTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2in src/catch2/internal/catch_template_test_registry.hpp needs at most a matching call-site rename. If a general restructuring proves too invasive, fall back to a narrowly scoped#if defined(__clang__) && __clang_major__ >= 20 && __clang_major__ < 22alternative formulation, matching Catch2's existing compiler-workaround style.Building Catch2 3.15.0's SelfTest suite fails under clang 20/21 with libc++ (observed on macOS and Alpine via meson wrapdb CI). The failing construct is
TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", ..., std::tuple, (int, (int, double), (int, double, float)))in tests/SelfTest/UsageTests/Misc.tests.cpp:391. Clang reports "no matching function for call to 'get_wrapper'": the template-template overload ofget_wrappergenerated byINTERNAL_CATCH_TYPE_GENin src/catch2/internal/catch_preprocessor.hpp (thepriority_tag<1>overload returningTemplateTypeList<Cs...>) hits a "conflicting deduction 'std::tuple' against 'type-parameter-0-0'" substitution failure. The reporter notes clang 22 compiles it fine, so this is likely a clang 20/21 deduction bug, but those compiler versions ship on current macOS and Alpine toolchains, making a Catch2-side workaround valuable.Closes #3115
GitHub Issues