Skip to content
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

Assertion failed: Result.isInvalid() && "C++ binary operator overloading is missing candidates!" #62870

Open
porglezomp opened this issue May 22, 2023 · 5 comments
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-valid

Comments

@porglezomp
Copy link
Contributor

porglezomp commented May 22, 2023

Clang hits an assertion when trying to compile an ext_vector_type << enum.
Example reduced case:

enum Enum { EXAMPLE = 3 };

using v4i = int __attribute__((ext_vector_type(4)));

v4i shift(v4i a, Enum b) {
    return a << b;
}
Assertion failed: Result.isInvalid() && "C++ binary operator overloading is missing candidates!", file C:\Users\acct\Development\llvm-project\clang\lib\Sema\SemaOverload.cpp, line 14233
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\Users\\acct\\Development\\llvm-project\\build\\bin\\clang.exe -c C:\\tmp\\minimal.cpp
1.      C:\tmp\minimal.cpp:6:18: current parser token ';'
2.      C:\tmp\minimal.cpp:5:26: parsing function body 'shift'
3.      C:\tmp\minimal.cpp:5:26: in compound statement ('{}')
Exception Code: 0x80000003
 #0 0x00007ff76e853f55 HandleAbort C:\Users\acct\Development\llvm-project\llvm\lib\Support\Windows\Signals.inc:419:0
 #1 0x00007ffe29531881 (C:\windows\System32\ucrtbase.dll+0x71881)
 #2 0x00007ffe29532851 (C:\windows\System32\ucrtbase.dll+0x72851)
 #3 0x00007ffe2953426e (C:\windows\System32\ucrtbase.dll+0x7426e)
 #4 0x00007ffe29534165 (C:\windows\System32\ucrtbase.dll+0x74165)
 #5 0x00007ffe295344f1 (C:\windows\System32\ucrtbase.dll+0x744f1)
 #6 0x00007ff7718e0bb8 llvm::ArrayRef<clang::OverloadCandidate *>::{ctor} C:\Users\acct\Development\llvm-project\llvm\include\llvm\ADT\ArrayRef.h:89:0
 #7 0x00007ff7718e0bb8 clang::Sema::CreateOverloadedBinOp(class clang::SourceLocation, enum clang::BinaryOperatorKind, class clang::UnresolvedSetImpl const &, class clang::Expr *, class clang::Expr *, bool, bool, class clang::FunctionDecl *) C:\Users\acct\Development\llvm-project\clang\lib\Sema\SemaOverload.cpp:14234:0
 #8 0x00007ff77105d937 llvm::SmallVector<clang::DeclAccessPair,16>::{dtor} C:\Users\acct\Development\llvm-project\llvm\include\llvm\ADT\SmallVector.h:1207:0
 #9 0x00007ff77105d937 BuildOverloadedBinOp C:\Users\acct\Development\llvm-project\clang\lib\Sema\SemaExpr.cpp:15783:0
#10 0x00007ff771055bae clang::Sema::BuildBinOp(class clang::Scope *, class clang::SourceLocation, enum clang::BinaryOperatorKind, class clang::Expr *, class clang::Expr *) C:\Users\acct\Development\llvm-project\clang\lib\Sema\SemaExpr.cpp:15931:0
#11 0x00007ff7710471fe clang::Sema::ActOnBinOp(class clang::Scope *, class clang::SourceLocation, enum clang::tok::TokenKind, class clang::Expr *, class clang::Expr *) C:\Users\acct\Development\llvm-project\clang\lib\Sema\SemaExpr.cpp:15734:0
#12 0x00007ff770d80a7c clang::ActionResult<clang::Expr *,1>::isInvalid C:\Users\acct\Development\llvm-project\clang\include\clang\Sema\Ownership.h:207:0
#13 0x00007ff770d80a7c clang::Parser::ParseRHSOfBinaryExpression(class clang::ActionResult<class clang::Expr *, 1>, enum clang::prec::Level) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseExpr.cpp:633:0
#14 0x00007ff770d71ef9 clang::Parser::ParseAssignmentExpression(enum clang::Parser::TypeCastState) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseExpr.cpp:179:0
#15 0x00007ff770d7a39a clang::Parser::ParseExpression(enum clang::Parser::TypeCastState) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseExpr.cpp:127:0
#16 0x00007ff770da0ffb clang::Parser::ParseReturnStatement(void) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseStmt.cpp:2398:0
#17 0x00007ff770da2996 clang::Parser::ParseStatementOrDeclarationAfterAttributes(class llvm::SmallVector<class clang::Stmt *, 32> &, enum clang::Parser::ParsedStmtContext, class clang::SourceLocation *, class clang::ParsedAttributes &, class clang::ParsedAttributes &) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseStmt.cpp:329:0
#18 0x00007ff770da214b clang::Parser::ParseStatementOrDeclaration(class llvm::SmallVector<class clang::Stmt *, 32> &, enum clang::Parser::ParsedStmtContext, class clang::SourceLocation *) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseStmt.cpp:119:0
#19 0x00007ff770d9aabf clang::Parser::ParseCompoundStatementBody(bool) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseStmt.cpp:1200:0
#20 0x00007ff770d9e281 clang::ActionResult<clang::Stmt *,1>::isInvalid C:\Users\acct\Development\llvm-project\clang\include\clang\Sema\Ownership.h:207:0
#21 0x00007ff770d9e281 clang::Parser::ParseFunctionStatementBody(class clang::Decl *, class clang::Parser::ParseScope &) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseStmt.cpp:2467:0
#22 0x00007ff770cf85d3 clang::Parser::ParseScope::{dtor} C:\Users\acct\Development\llvm-project\clang\include\clang\Parse\Parser.h:1149:0
#23 0x00007ff770cf85d3 clang::Parser::ParseFunctionDefinition(class clang::ParsingDeclarator &, struct clang::Parser::ParsedTemplateInfo const &, class clang::Parser::LateParsedAttrList *) C:\Users\acct\Development\llvm-project\clang\lib\Parse\Parser.cpp:1471:0
#24 0x00007ff770d2612d clang::Parser::ParseDeclGroup(class clang::ParsingDeclSpec &, enum clang::DeclaratorContext, class clang::ParsedAttributes &, class clang::SourceLocation *, struct clang::Parser::ForRangeInit *) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseDecl.cpp:2177:0
#25 0x00007ff770cf6378 clang::Parser::ParseDeclOrFunctionDefInternal(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec &, enum clang::AccessSpecifier) C:\Users\acct\Development\llvm-project\clang\lib\Parse\Parser.cpp:1211:0
#26 0x00007ff770cf674c llvm::SaveAndRestore<bool>::{dtor} C:\Users\acct\Development\llvm-project\llvm\include\llvm\Support\SaveAndRestore.h:29:0
#27 0x00007ff770cf674c clang::Parser::ObjCDeclContextSwitch::{dtor} C:\Users\acct\Development\llvm-project\clang\include\clang\Parse\Parser.h:1047:0
#28 0x00007ff770cf674c clang::Parser::ParseDeclarationOrFunctionDefinition(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *, enum clang::AccessSpecifier) C:\Users\acct\Development\llvm-project\clang\lib\Parse\Parser.cpp:1225:0
#29 0x00007ff770cf72a7 clang::Parser::ParseExternalDeclaration(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *) C:\Users\acct\Development\llvm-project\clang\lib\Parse\Parser.cpp:1045:0
#30 0x00007ff770cfc394 clang::Parser::ParseTopLevelDecl(class clang::OpaquePtr<class clang::DeclGroupRef> &, enum clang::Sema::ModuleImportState &) C:\Users\acct\Development\llvm-project\clang\lib\Parse\Parser.cpp:742:0
#31 0x00007ff770cf0674 clang::ParseAST(class clang::Sema &, bool, bool) C:\Users\acct\Development\llvm-project\clang\lib\Parse\ParseAST.cpp:163:0
#32 0x00007ff76f5dd6d0 clang::ASTFrontendAction::ExecuteAction(void) C:\Users\acct\Development\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1166:0
#33 0x00007ff7733d1c5b clang::CodeGenAction::ExecuteAction(void) C:\Users\acct\Development\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1174:0
#34 0x00007ff76f5dd405 clang::FrontendAction::Execute(void) C:\Users\acct\Development\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1060:0
#35 0x00007ff76f5926bb llvm::Error::getPtr C:\Users\acct\Development\llvm-project\llvm\include\llvm\Support\Error.h:271:0
#36 0x00007ff76f5926bb llvm::Error::operator bool C:\Users\acct\Development\llvm-project\llvm\include\llvm\Support\Error.h:235:0
#37 0x00007ff76f5926bb clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) C:\Users\acct\Development\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1049:0
#38 0x00007ff76f6a9d2f clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) C:\Users\acct\Development\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:264:0
#39 0x00007ff76cb6c651 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) C:\Users\acct\Development\llvm-project\clang\tools\driver\cc1_main.cpp:249:0
#40 0x00007ff76cb64654 ExecuteCC1Tool C:\Users\acct\Development\llvm-project\clang\tools\driver\driver.cpp:375:0
#41 0x00007ff76f448551 clang::driver::CC1Command::Execute::__l7::<lambda_46e20d7a705ea64f8f76933693c402e0>::operator() C:\Users\acct\Development\llvm-project\clang\lib\Driver\Job.cpp:439:0
#42 0x00007ff76f448551 llvm::function_ref<void __cdecl(void)>::callback_fn<<lambda_46e20d7a705ea64f8f76933693c402e0> > C:\Users\acct\Development\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45:0
#43 0x00007ff76e83b0da llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) C:\Users\acct\Development\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:235:0
#44 0x00007ff76f448efb clang::driver::CC1Command::Execute(class llvm::ArrayRef<class std::optional<class llvm::StringRef>>, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> *, bool *) const C:\Users\acct\Development\llvm-project\clang\lib\Driver\Job.cpp:439:0
#45 0x00007ff76f39393d std::_Func_class<void,clang::driver::Command const &,int>::_Empty C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional:883:0
#46 0x00007ff76f39393d std::function<void __cdecl(clang::driver::Command const &,int)>::operator bool C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional:1125:0
#47 0x00007ff76f39393d clang::driver::Compilation::ExecuteCommand(class clang::driver::Command const &, class clang::driver::Command const *&, bool) const C:\Users\acct\Development\llvm-project\clang\lib\Driver\Compilation.cpp:200:0
#48 0x00007ff76f393c7f clang::driver::Compilation::ExecuteJobs(class clang::driver::JobList const &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &, bool) const C:\Users\acct\Development\llvm-project\clang\lib\Driver\Compilation.cpp:253:0
#49 0x00007ff76f36d6a9 llvm::SmallVectorBase<unsigned int>::empty C:\Users\acct\Development\llvm-project\llvm\include\llvm\ADT\SmallVector.h:94:0
#50 0x00007ff76f36d6a9 clang::driver::Driver::ExecuteCompilation(class clang::driver::Compilation &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) C:\Users\acct\Development\llvm-project\clang\lib\Driver\Driver.cpp:1868:0
#51 0x00007ff76cb678ae clang_main(int, char **, struct llvm::ToolContext const &) C:\Users\acct\Development\llvm-project\clang\tools\driver\driver.cpp:544:0
#52 0x00007ff76cb79bb4 main C:\Users\acct\Development\llvm-project\build\tools\clang\tools\driver\clang-driver.cpp:16:0
#53 0x00007ff77292e608 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
#54 0x00007ff77292e608 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#55 0x00007ffe2af77614 (C:\windows\System32\KERNEL32.DLL+0x17614)
#56 0x00007ffe2bb026a1 (C:\windows\SYSTEM32\ntdll.dll+0x526a1)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (git@github.com:llvm/llvm-project.git cdd439df969d166b3ebab1044fcc531be9912603)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\acct\Development\llvm-project\build\bin
@porglezomp porglezomp added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] labels May 22, 2023
@porglezomp porglezomp self-assigned this May 22, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented May 22, 2023

@llvm/issue-subscribers-clang-frontend

@porglezomp
Copy link
Contributor Author

@shafik
Copy link
Collaborator

shafik commented May 22, 2023

I don't know if this is a duplicate but looks very similar to: #27443

@shafik shafik added confirmed Verified by a second party crash-on-valid labels May 22, 2023
@porglezomp
Copy link
Contributor Author

They're both caused by the builtins handling more cases than the builtin overload sets, but will have different fixes.
It hits this if the added overloads (especially the added builtin overloads) don't contain a viable operator, but then the actual implementation of the builtin accepts the types.

For the shift case, no operators were generating vector/scalar overloads, but the shift builtin handled the vector/enum.

@AaronBallman
Copy link
Collaborator

Here is another asserting test case that appears to be the same problem:

typedef int vint __attribute__((__vector_size__(16)));

struct S {
  int operator+(int r);
};

void f() {
  S s;
  vint v;
  (void)(s+v);
}

@EugeneZelenko EugeneZelenko removed the crash Prefer [crash-on-valid] or [crash-on-invalid] label Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-valid
Projects
None yet
Development

No branches or pull requests

5 participants