Hello all,
I’m seeing an assert when compiling code like this:
template struct X { };
void f(X<8> x) {
X<7> y;
y = x;
}
DiffTemplate/GetExpr (in ASTDiagnostic.cpp) assumes that the non-type args are expressions:
void DiffTemplate() {
// Handle Expressions
if (NonTypeTemplateParmDecl *DefaultNTTPD =
dyn_cast(ParamND)) {
Expr *FromExpr, *ToExpr;
GetExpr(FromIter, DefaultNTTPD, FromExpr);
GetExpr(ToIter, DefaultNTTPD, ToExpr);
}}
void GetExpr(const TSTiterator &Iter, ) {
if (!Iter.isEnd())
ArgExpr = Iter->getAsExpr();}
But in some cases they are integral values (e.g. Iter->getKind() == TemplateArgument::Integral). As a result, an assertion inside Iter->getAsExpr() fails.
Is DiffTemplate broken or should the integral arg never have found it’s way to it?
BTW, I modified GetExpr to create an Expr from the Integral arg and that seemed to work, but I’m not sure if that’s the right thing to do.
Cheers,
Matthew C.