Repository navigation
Fix SFINAE calling a function template with deduced return type and pending definition - #322
cpplearner wants to merge 1 commit into
Conversation
|
daveedvdv-nvidia
left a comment
There was a problem hiding this comment.
Thanks for taking this on!
I've created issue #453 from the discussion.
The fix looks fine to me (I made a note of one stylistic nit). To be complete we need a few more things:
| tsym = prototype_template_if_template_symbol(tip->template_sym); | ||
| if (tsym->defined) { | ||
| could_be_instantiated = TRUE; | ||
| } else if (has_pending_template_definition_from_module( |
There was a problem hiding this comment.
I'd slightly prefer a single if (tsym->defined || has_pending... ) ... statement here.
d2c8e30 to
a137961
Compare
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Recognize pending module definitions src/exprutil.c |
The suppressed-diagnostic check now treats a pending module template definition as evidence that a routine with an undeduced return type could be instantiated. |
Test imported template constraint tests/tests/regressions/modules/gh-453-template-return-auto/*, src/pending_changes/gh-453.txt |
The module exports a function template with a deduced return type. The regression test checks that a requires-expression accepts the call, and the changelog records the fix. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
edgcpp/compiler#453— Describes the same failure for a module-imported function template with a deduced return type in a requires-expression or SFINAE context.
Suggested labels: bug
Suggested reviewers: daveedvdv-nvidia, wchilders-nvidia
Merge Risk: 
Minimal · up to a1379
-
No actionable merge-blocking risk is established by this change.
Pre-merge checks: 
4
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Done. The test depends on an |
|
AcknowlEDG review results updated for
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
We took all of the MSVC IFC files out of the test when opening up the repo because of legal concerns with distributing them. I'm not sure those have been resolved, so I think I'd unfortunately prefer to pull this as an E-IFC test that would fail (because the writing support is not currently present). I have some old patches I should push up somewhere that were WIP expansions of friend and template support for E-IFC. |
With modules, it is possible that a function template definition exists in a module but the definition is not yet loaded. In such a case,
routine->definedis false, despite the existence of a definition. Previously, substitution failed if such a function template is called in a SFINAE context and the function template has a deduced return type. This is fixed in this PR.See #242 for an example.
Fixes #242
Summary by CodeRabbit