[llvm-bugs] [Bug 43151] New: In Sema::SubstExceptionSpec: Assertion `ESI.Type != EST_Uninstantiated' failed
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 28 12:27:23 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43151
Bug ID: 43151
Summary: In Sema::SubstExceptionSpec: Assertion `ESI.Type !=
EST_Uninstantiated' failed
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: aaronpuchert at alice-dsl.net
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Created attachment 22445
--> https://bugs.llvm.org/attachment.cgi?id=22445&action=edit
Small reproducer for the bug, compile with -std=c++17.
Compiling the following code with "-fsyntax-only -std=c++17" produces an
assertion failure:
template<typename T>
struct X {
using self = X<T>;
template<bool noex>
void f() noexcept(noex)
{
auto x = &self::f<noex>;
}
};
void g()
{
X<int> x;
x.f<true>();
}
The trace shows:
1. <eof> parser at end of file
2. template-crash.cpp:6:8: instantiating function definition
'X<int>::f<true>'
The issue disappears when removing "-std=c++17", probably because the exception
specification is not part of the type then.
The function is called from clang::Sema::SubstituteExplicitTemplateArguments,
where we have EPI.ExceptionSpec.Type = clang::EST_Uninstantiated and
EPI.ExceptionSpec.SourceDecl = Function. On the other hand, the type of
EPI.ExceptionSpec.SourceTemplate has an ExceptionSpec with Type =
clang::EST_DependentNoexcept. So it seems we should be passing that one to
Sema::SubstExceptionSpec instead.
Indeed, the following seems to fix the assertion (and not introduce new
issues):
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3112,6 +3112,13 @@ Sema::SubstituteExplicitTemplateArguments(
// so substitution into the type must also substitute into the exception
// specification.
SmallVector<QualType, 4> ExceptionStorage;
+ if (EPI.ExceptionSpec.Type == EST_Uninstantiated) {
+ assert(Function == EPI.ExceptionSpec.SourceDecl);
+ const auto *TplType = EPI.ExceptionSpec.SourceTemplate->getType()
+ ->getAs<FunctionProtoType>();
+ EPI.ExceptionSpec = TplType->getExtProtoInfo().ExceptionSpec;
+ assert(EPI.ExceptionSpec.Type != EST_Uninstantiated);
+ }
if (getLangOpts().CPlusPlus17 &&
SubstExceptionSpec(
Function->getLocation(), EPI.ExceptionSpec, ExceptionStorage,
But this seems like a hack, since in other instances the ExceptionSpec is
already instantiated correctly.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190828/f77be45a/attachment.html>
More information about the llvm-bugs
mailing list