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

[clang] ICE: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed. boost-1.83 and clang-17.0.0_rc2 #64885

Closed
parona-source opened this issue Aug 22, 2023 · 6 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form

Comments

@parona-source
Copy link

LLVM from llvmorg-17.0.0-rc2 tag

https://bugs.gentoo.org/912678

clang++: /usr/lib/llvm/17/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = clang::CXXConstructExpr, From = clang::Expr]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
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: clang++ -fvisibility-inlines-hidden -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O2 -pipe -std=c++17 -fPIC -m64 -pthread -finline-functions -Wno-inline -Wall -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_URL_DYN_LINK=1 -DBOOST_URL_SOURCE -DNDEBUG -I. -c -o bin.v2/libs/url/build/gcc-4.2/gentoorelease/pch-off/threading-multi/visibility-hidden/segments_view.o libs/url/src/segments_view.cpp
1.      libs/url/src/segments_view.cpp:34:1: current parser token '{'
2.      libs/url/src/segments_view.cpp:18:1: parsing namespace 'boost'
3.      libs/url/src/segments_view.cpp:19:1: parsing namespace 'boost::urls'
 #0 0x00007fc9f84ff836 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17+libcxx.so+0x4aff836)
 #1 0x00007fc9f84fcd30 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/17/bin/../lib64/libLLVM-17+libcxx.so+0x4afcd30)
 #2 0x00007fc9f840bfd9 (/usr/lib/llvm/17/bin/../lib64/libLLVM-17+libcxx.so+0x4a0bfd9)
 #3 0x00007fc9f3759930 (/lib64/libc.so.6+0x38930)
 #4 0x00007fc9f37a69fc __pthread_kill_implementation /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/nptl/pthread_kill.c:44:76
 #5 0x00007fc9f3759892 raise /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007fc9f37434ad abort /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/stdlib/abort.c:81:7
 #7 0x00007fc9f37433d5 _nl_load_domain /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/intl/loadmsgcat.c:1177:9
 #8 0x00007fc9f3752652 (/lib64/libc.so.6+0x31652)
 #9 0x00007fc9ffea0080 clang::Sema::BuildDelegatingInitializer(clang::TypeSourceInfo*, clang::Expr*, clang::CXXRecordDecl*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Sema/SemaDeclCXX.cpp:4643:5
#10 0x00007fc9ffe9f744 clang::Sema::BuildBaseInitializer(clang::QualType, clang::TypeSourceInfo*, clang::Expr*, clang::CXXRecordDecl*, clang::SourceLocation) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Sema/SemaDeclCXX.cpp:4724:14
#11 0x00007fc9ffe9decf clang::Sema::BuildMemInitializer(clang::Decl*, clang::Scope*, clang::CXXScopeSpec&, clang::IdentifierInfo*, clang::OpaquePtr<clang::QualType>, clang::DeclSpec const&, clang::SourceLocation, clang::Expr*, clang::SourceLocation) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Sema/SemaDeclCXX.cpp:0:0
#12 0x00007fc9ffe9e7f1 clang::Sema::ActOnMemInitializer(clang::Decl*, clang::Scope*, clang::CXXScopeSpec&, clang::IdentifierInfo*, clang::OpaquePtr<clang::QualType>, clang::DeclSpec const&, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceLocation) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Sema/SemaDeclCXX.cpp:4298:10
#13 0x00007fc9ff20fd59 clang::Parser::ParseMemInitializer(clang::Decl*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:3866:20
#14 0x00007fc9ff20ecf8 clang::Parser::ParseConstructorInitializer(clang::Decl*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:0:0
#15 0x00007fc9ff2b9dda clang::Token::is(clang::tok::TokenKind) const /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Lex/Token.h:98:49
#16 0x00007fc9ff2b9dda clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:1459:14
#17 0x00007fc9ff1d7e76 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDecl.cpp:2197:18
#18 0x00007fc9ff2b8635 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:0:10
#19 0x00007fc9ff2b7de3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:0:0
#20 0x00007fc9ff2b6d03 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:0:14
#21 0x00007fc9ff1fac89 clang::AttributePool::~AttributePool() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Sema/ParsedAttr.h:704:22
#22 0x00007fc9ff1fac89 clang::ParsedAttributes::~ParsedAttributes() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Sema/ParsedAttr.h:920:7
#23 0x00007fc9ff1fac89 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:263:5
#24 0x00007fc9ff1fa0a3 clang::Parser::ParseScope::Exit() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Parse/Parser.h:1143:15
#25 0x00007fc9ff1fa0a3 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:242:18
#26 0x00007fc9ff1d5df8 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDecl.cpp:0:12
#27 0x00007fc9ff2b6794 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:0:14
#28 0x00007fc9ff1fac89 clang::AttributePool::~AttributePool() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Sema/ParsedAttr.h:704:22
#29 0x00007fc9ff1fac89 clang::ParsedAttributes::~ParsedAttributes() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Sema/ParsedAttr.h:920:7
#30 0x00007fc9ff1fac89 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:263:5
#31 0x00007fc9ff1fa0a3 clang::Parser::ParseScope::Exit() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/include/clang/Parse/Parser.h:1143:15
#32 0x00007fc9ff1fa0a3 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDeclCXX.cpp:242:18
#33 0x00007fc9ff1d5df8 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseDecl.cpp:0:12
#34 0x00007fc9ff2b6794 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:0:14
#35 0x00007fc9ff2b4599 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/Parser.cpp:742:10
#36 0x00007fc9ff1c128e clang::ParseAST(clang::Sema&, bool, bool) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Parse/ParseAST.cpp:162:5
#37 0x00007fca0167a623 clang::FrontendAction::Execute() /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Frontend/FrontendAction.cpp:1062:10
#38 0x00007fca015e1a7d llvm::Error::getPtr() const /usr/lib/llvm/17/include/llvm/Support/Error.h:270:42
#39 0x00007fca015e1a7d llvm::Error::operator bool() /usr/lib/llvm/17/include/llvm/Support/Error.h:233:16
#40 0x00007fca015e1a7d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Frontend/CompilerInstance.cpp:1053:23
#41 0x00007fca01708f26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:0:0
#42 0x000055c1d92113d9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/tools/driver/cc1_main.cpp:0:0
#43 0x000055c1d920e81f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/tools/driver/driver.cpp:0:12
#44 0x00007fca012013e9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0::operator()() const /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Driver/Job.cpp:440:30
#45 0x00007fca012013e9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) /usr/lib/llvm/17/include/llvm/ADT/STLFunctionalExtras.h:45:12
#46 0x00007fc9f840bc46 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm/17/bin/../lib64/libLLVM-17+libcxx.so+0x4a0bc46)
#47 0x00007fca012009ed clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Driver/Job.cpp:440:7
#48 0x00007fca011bf43f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Driver/Compilation.cpp:0:0
#49 0x00007fca011bf7de clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Driver/Compilation.cpp:253:13
#50 0x00007fca011df88c llvm::SmallVectorBase<unsigned int>::empty() const /usr/lib/llvm/17/include/llvm/ADT/SmallVector.h:94:46
#51 0x00007fca011df88c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/lib/Driver/Driver.cpp:1906:23
#52 0x000055c1d920d736 clang_main(int, char**, llvm::ToolContext const&) /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/clang/tools/driver/driver.cpp:0:0
#53 0x000055c1d921dda2 main /var/tmp/notmpfs/portage/sys-devel/clang-17.0.0_rc2/work/x/y/clang-abi_x86_64.amd64/tools/driver/clang-driver.cpp:15:3
#54 0x00007fc9f374478a __libc_start_call_main /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#55 0x00007fc9f3744845 call_init /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/csu/../csu/libc-start.c:128:20
#56 0x00007fc9f3744845 __libc_start_main /var/tmp/notmpfs/portage/sys-libs/glibc-2.37-r4/work/glibc-2.37/csu/../csu/libc-start.c:347:5
#57 0x000055c1d920a791 _start (/usr/lib/llvm/17/bin/clang-17+0x11791)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 17.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/17/bin
Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang++.cfg
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 22, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 22, 2023

@llvm/issue-subscribers-clang-frontend

@parona-source
Copy link
Author

parona-source commented Aug 22, 2023

@shafik shafik added the needs-reduction Large reproducer that should be reduced into a simpler form label Aug 22, 2023
@shafik
Copy link
Collaborator

shafik commented Aug 22, 2023

It is possible a duplicate of: #39319

@parona-source
Copy link
Author

The build succeeds with clang-16. Will look into reducing.

@parona-source
Copy link
Author

parona-source commented Aug 22, 2023

Testing the reproducer in #39319 (comment) it fails similarily to here with clang-17. It succeeds with clang-15 and clang-16 though.

To my eye it looks like a duplicate, just odd seeing how clang-15 and clang-16 didn't suffer from this.

Plausibly stopped triggering in clang-14 or clang-15 and now it reappears?

@parona-source
Copy link
Author

Closing as duplicate

@parona-source parona-source closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
shafik added a commit that referenced this issue Dec 8, 2023
…ction if we are going use copy elision

ResolveConstructorOverload needs to check properly if we are going to use copy
elision we can't use a conversion function.

This fixes:

#39319
#60182
#62157
#64885
#65568

Differential Revision: https://reviews.llvm.org/D148474
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Mar 20, 2024
  [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

  ResolveConstructorOverload needs to check properly if we are going to use copy
  elision we can't use a conversion function.

  This fixes:

  llvm/llvm-project#39319
  llvm/llvm-project#60182
  llvm/llvm-project#62157
  llvm/llvm-project#64885
  llvm/llvm-project#65568

  Differential Revision: https://reviews.llvm.org/D148474

This should fix 'Assertion failed: (isa<To>(Val) && "cast<Ty>() argument
of incompatible type!")' errors when building devel/boost-libs,
specifically libs/url/src/segments_view.cpp.

Bump __FreeBSD_version so this fix can easily be detected from
devel/boost-all/compiled.mk.

PR:		273335
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Mar 23, 2024
  [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

  ResolveConstructorOverload needs to check properly if we are going to use copy
  elision we can't use a conversion function.

  This fixes:

  llvm/llvm-project#39319
  llvm/llvm-project#60182
  llvm/llvm-project#62157
  llvm/llvm-project#64885
  llvm/llvm-project#65568

  Differential Revision: https://reviews.llvm.org/D148474

This should fix 'Assertion failed: (isa<To>(Val) && "cast<Ty>() argument
of incompatible type!")' errors when building devel/boost-libs,
specifically libs/url/src/segments_view.cpp.

Bump __FreeBSD_version so this fix can easily be detected from
devel/boost-all/compiled.mk.

PR:		273335
(cherry picked from commit bcd401b)
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Mar 23, 2024
  [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

  ResolveConstructorOverload needs to check properly if we are going to use copy
  elision we can't use a conversion function.

  This fixes:

  llvm/llvm-project#39319
  llvm/llvm-project#60182
  llvm/llvm-project#62157
  llvm/llvm-project#64885
  llvm/llvm-project#65568

  Differential Revision: https://reviews.llvm.org/D148474

This should fix 'Assertion failed: (isa<To>(Val) && "cast<Ty>() argument
of incompatible type!")' errors when building devel/boost-libs,
specifically libs/url/src/segments_view.cpp.

Bump __FreeBSD_version so this fix can easily be detected from
devel/boost-all/compiled.mk.

PR:		273335
(cherry picked from commit bcd401b)
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" crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form
Projects
None yet
Development

No branches or pull requests

4 participants