-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] Ill-formed default argument treated as building a deduction guide causes crash #65522
Comments
@llvm/issue-subscribers-clang-frontend |
Hi @shafik, sorry for the late response. I think you could just make it diagnose like a regular instantiation context (CodeSynthesisContext::TemplateInstantiation, llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp Lines 769 to 776 in 4b9c2cf
|
So I tried a quick experiment and moved the case CodeSynthesisContext::BuildingDeductionGuides:
case CodeSynthesisContext::TemplateInstantiation: { and I am getting a } else if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(D)) {
Diags.Report(Active->PointOfInstantiation,
diag::note_template_class_instantiation_here)
<< CTD << Active->InstantiationRange; and that looks consistent with your change which takes InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
TemplateDecl *Entity, BuildingDeductionGuidesTag,
SourceRange InstantiationRange = SourceRange()); I am not super familiar with this area, so is the If not, can you give a more detailed explanation. |
I'm trying to fix this locally. However |
All new pull request need to be done on github, you can find documentation here: https://llvm.org/docs/GitHub.html Also on discord there is the github-pull-requests channel |
Is D148474 on GitHub PR yet? I'm trying to base my fix on D148474. So you could include the fix in D148474. |
No, I have not moved it over. I was hoping to try and get it done w/o moving it over. The code I provided in this bug report is one of my tests from that PR but it crashes on trunk now: https://godbolt.org/z/cP8dcrWP6 and so you can implement a fix w/o my PR. |
Thanks. I'll get back soon. |
In some cases where ill-formed code could be interpreted as a deduction guide we can crash because we reach an unreachable path. This fixes this issue by introducing a diagnostic instead. Fixes: llvm#65522
Given the following C++:
This causes a crash on clang trunk: https://godbolt.org/z/dK43xx1KT
This was introduced by: https://reviews.llvm.org/D139837 and is currently blocking: https://reviews.llvm.org/D148474
Unreachable hit:
UNREACHABLE executed at /root/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1068!
Backtrace:
The text was updated successfully, but these errors were encountered: