Clang FE parser assert

Hello

I am getting an assert on trunk llvm in our code base. Is this a FE bug? At least to me code looks valid (not my code).

Repro
clang++ main.cpp -c -o main.o

#include <cstdint>
typedef int32_t __m256si_u
    __attribute__((__vector_size__(32), __may_alias__, __aligned__(1)));
template <uint8_t width>
void foo(const int* rows) {
auto indices = *reinterpret_cast<const __m256si_u*>(rows) * width;
}

Partial stack:

#11 0x0000564d2ea190c3 canConvertIntToOtherIntTy(clang::Sema&, clang::ActionResult<clang::Expr*, true>*, clang::QualType) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:0:29
#12 0x0000564d2ea190c3 tryGCCVectorConvertAndSplat(clang::Sema&, clang::ActionResult<clang::Expr*, true>*, clang::ActionResult<clang::Expr*, true>*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:10964:9
#13 0x0000564d2ea13d67 clang::Sema::CheckVectorOperands(clang::ActionResult<clang::Expr*, true>&, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, bool, bool, bool, bool, bool) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:11175:11
#14 0x0000564d2ea19c0e clang::Sema::CheckMultiplyDivideOperands(clang::ActionResult<clang::Expr*, true>&, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, bool, bool) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:11452:12
#15 0x0000564d2ea060d6 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:0:16
#16 0x0000564d2e9f1968 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Sema/SemaExpr.cpp:16021:1
#17 0x0000564d2e5055c1 clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseExpr.cpp:632:21
#18 0x0000564d2e504317 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:10
#19 0x0000564d2e55639a clang::Parser::ParseInitializer() /home/ayermolo/local/upstream-llvm/llvm-project/clang/include/clang/Parse/Parser.h:0:0
#20 0x0000564d2e55639a clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2614:25
#21 0x0000564d2e553793 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2348:21
#22 0x0000564d2e5529b8 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:10
#23 0x0000564d2e55237f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:0
#24 0x0000564d2e598637 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:16
#25 0x0000564d2e596812 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:117:20
#26 0x0000564d2e5a0821 clang::Parser::ParseCompoundStatementBody(bool) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:1205:11
#27 0x0000564d2e5a185f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:2468:21
#28 0x0000564d2e4e4f56 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/Parser.cpp:0:0
#29 0x0000564d2e588ce7 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseTemplate.cpp:0:0
#30 0x0000564d2e586f0d clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseTemplate.cpp:0:0
#31 0x0000564d2e586826 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseTemplate.cpp:0:0
#32 0x0000564d2e552196 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:1971:10
#33 0x0000564d2e4e1f93 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/Parser.cpp:0:0
#34 0x0000564d2e4e04b6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/Parser.cpp:742:10
#35 0x0000564d2e4daf1e clang::ParseAST(clang::Sema&, bool, bool) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:162:5
#36 0x0000564d2cc25a3f clang::FrontendAction::Execute() /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1067:10
#37 0x0000564d2cb9aa1d llvm::Error::getPtr() const /home/ayermolo/local/upstream-llvm/llvm-project/llvm/include/llvm/Support/Error.h:270:42
#38 0x0000564d2cb9aa1d llvm::Error::operator bool() /home/ayermolo/local/upstream-llvm/llvm-project/llvm/include/llvm/Support/Error.h:233:16
#39 0x0000564d2cb9aa1d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1054:23
#40 0x0000564d2cd032f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/ayermolo/local/upstream-llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272:25

Any assertion on user input is a bug. The traceback does make it look like a Clang problem; you should file an issue.

1 Like