[llvm-bugs] [Bug 51537] New: [concepts] [ice] deduction guide

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 19 05:22:57 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51537

            Bug ID: 51537
           Summary: [concepts] [ice] deduction guide
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at marehr.dialup.fu-berlin.de
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hi clang-team,

the following code ices:

```
template <typename> struct index_traits {
  template <typename new_index_type> using rebind = int;
};

template <template <typename> typename rebind> struct index_traits_has_rebind {
  static constexpr bool value = true;
};

template <typename index_t>
concept index_concept = requires(index_t a, index_t b) {
  requires index_traits_has_rebind<
      index_traits<index_t>::template rebind>::value;
};

template <typename index_t>
requires(index_concept<index_t>) struct matrix_index {
  constexpr matrix_index(index_t const, index_t const) noexcept;
};

template <index_concept index_t>
matrix_index(index_t, index_t) -> matrix_index<index_t>;

template <typename = int> struct coordinate_matrix {
  using value_type = decltype(matrix_index{int{}, int{}});
};
```

https://godbolt.org/z/4hP6zjn7G

with the following error:

```
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
/app/output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics -std=c++20 <source>
1.      <source>:24:57: current parser token ')'
2.      <source>:23:27: parsing struct/union/class body 'coordinate_matrix'
 #0 0x000055cf9a14036f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055cf9a13e230 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34fe230)
 #2 0x000055cf9a08f218 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fb379ac73c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x000055cf9c69f678 (anonymous
namespace)::MarkUsedTemplateParameterVisitor::TraverseTemplateName(clang::TemplateName)
SemaTemplateDeduction.cpp:0:0
 #5 0x000055cf9c69f945 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseTemplateArgumentLoc(clang::TemplateArgumentLoc
const&) SemaTemplateDeduction.cpp:0:0
 #6 0x000055cf9c69fe79 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseTypeLoc(clang::TypeLoc)
SemaTemplateDeduction.cpp:0:0
 #7 0x000055cf9c6a0483 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc)
SemaTemplateDeduction.cpp:0:0
 #8 0x000055cf9c6a96a4 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseDependentScopeDeclRefExpr(clang::DependentScopeDeclRefExpr*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) SemaTemplateDeduction.cpp:0:0
 #9 0x000055cf9c6952a1 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) SemaTemplateDeduction.cpp:0:0
#10 0x000055cf9c6962d9 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) (.part.5303)
SemaTemplateDeduction.cpp:0:0
#11 0x000055cf9c6ac0a0 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseRequiresExpr(clang::RequiresExpr*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) SemaTemplateDeduction.cpp:0:0
#12 0x000055cf9c694e01 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) SemaTemplateDeduction.cpp:0:0
#13 0x000055cf9c6962d9 clang::RecursiveASTVisitor<(anonymous
namespace)::MarkUsedTemplateParameterVisitor>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) (.part.5303)
SemaTemplateDeduction.cpp:0:0
#14 0x000055cf9c6ac69a clang::Sema::MarkUsedTemplateParameters(clang::Expr
const*, bool, unsigned int, llvm::SmallBitVector&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a6c69a)
#15 0x000055cf9c0ff84e substituteParameterMappings(clang::Sema&,
clang::NormalizedConstraint&, clang::ConceptDecl*,
llvm::ArrayRef<clang::TemplateArgument>, clang::ASTTemplateArgumentListInfo
const*) SemaConcept.cpp:0:0
#16 0x000055cf9c104df4
clang::NormalizedConstraint::fromConstraintExpr(clang::Sema&,
clang::NamedDecl*, clang::Expr const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54c4df4)
#17 0x000055cf9c10512a
clang::NormalizedConstraint::fromConstraintExprs(clang::Sema&,
clang::NamedDecl*, llvm::ArrayRef<clang::Expr const*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54c512a)
#18 0x000055cf9c104387
clang::Sema::getNormalizedAssociatedConstraints(clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54c4387)
#19 0x000055cf9c106e7a bool
subsumes<clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, bool&)::'lambda'(clang::AtomicConstraint
const&, clang::AtomicConstraint const&)>(clang::Sema&, clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, bool&,
clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, bool&)::'lambda'(clang::AtomicConstraint
const&, clang::AtomicConstraint const&)) SemaConcept.cpp:0:0
#20 0x000055cf9c108e72 clang::Sema::IsAtLeastAsConstrained(clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, clang::NamedDecl*,
llvm::ArrayRef<clang::Expr const*>, bool&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54c8e72)
#21 0x000055cf9c653f38
clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*,
clang::FunctionTemplateDecl*, clang::SourceLocation,
clang::TemplatePartialOrderingContext, unsigned int, unsigned int,
bool)::'lambda'()::operator()() const SemaTemplateDeduction.cpp:0:0
#22 0x000055cf9c69b892
clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*,
clang::FunctionTemplateDecl*, clang::SourceLocation,
clang::TemplatePartialOrderingContext, unsigned int, unsigned int, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a5b892)
#23 0x000055cf9c542119 clang::isBetterOverloadCandidate(clang::Sema&,
clang::OverloadCandidate const&, clang::OverloadCandidate const&,
clang::SourceLocation, clang::OverloadCandidateSet::CandidateSetKind)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5902119)
#24 0x000055cf9c548f87
clang::OverloadCandidateSet::BestViableFunction(clang::Sema&,
clang::SourceLocation, clang::OverloadCandidate*&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5908f87)
#25 0x000055cf9c40ee91
clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x57cee91)
#26 0x000055cf9c35fe39
clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x571fe39)
#27 0x000055cf9c3d00fd
clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr<clang::QualType>,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x57900fd)
#28 0x000055cf9bf536a1
clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53136a1)
#29 0x000055cf9bf456f3
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53056f3)
#30 0x000055cf9bf45593
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5305593)
#31 0x000055cf9bf46c26
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5306c26)
#32 0x000055cf9bf46cb8
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5306cb8)
#33 0x000055cf9bf49109
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5309109)
#34 0x000055cf9bf2e466 clang::Parser::ParseDecltypeSpecifier(clang::DeclSpec&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52ee466)
#35 0x000055cf9bf59a51
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool,
clang::IdentifierInfo**, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5319a51)
#36 0x000055cf9bef531c clang::Parser::TryAnnotateCXXScopeToken(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52b531c)
#37 0x000055cf9bf2140f
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52e140f)
#38 0x000055cf9bf23061
clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&,
clang::AccessSpecifier, clang::Parser::DeclSpecContext)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52e3061)
#39 0x000055cf9bf162c2 clang::Parser::ParseTypeName(clang::SourceRange*,
clang::DeclaratorContext, clang::AccessSpecifier, clang::Decl**,
clang::ParsedAttributes*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52d62c2)
#40 0x000055cf9bf2fa5d
clang::Parser::ParseAliasDeclarationAfterDeclarator(clang::Parser::ParsedTemplateInfo
const&, clang::SourceLocation, clang::Parser::UsingDeclarator&,
clang::SourceLocation&, clang::AccessSpecifier, clang::ParsedAttributes&,
clang::Decl**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52efa5d)
#41 0x000055cf9bf384bb
clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation,
clang::SourceLocation&, clang::ParsedAttributesWithRange&,
clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52f84bb)
#42 0x000055cf9bf3a05a
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52fa05a)
#43 0x000055cf9bf3bcc5
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::ParsedAttributesWithRange&, clang::TypeSpecifierType, clang::Decl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52fbcc5)
#44 0x000055cf9bf3c421
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52fc421)
#45 0x000055cf9bf3ea83
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::ParsedAttributesWithRange&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52fea83)
#46 0x000055cf9bf20628
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52e0628)
#47 0x000055cf9bfc217a
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x538217a)
#48 0x000055cf9bfc69e3
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53869e3)
#49 0x000055cf9bfc6f54
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5386f54)
#50 0x000055cf9bf24ea5
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52e4ea5)
#51 0x000055cf9befc14b
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52bc14b)
#52 0x000055cf9befd549
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52bd549)
#53 0x000055cf9bef0da9 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x52b0da9)
#54 0x000055cf9b097c12 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4457c12)
#55 0x000055cf9aa43381 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e03381)
#56 0x000055cf9a9e13e2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3da13e2)
#57 0x000055cf9ab0f713
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ecf713)
#58 0x000055cf97eca10c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x128a10c)
#59 0x000055cf97ec62dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#60 0x000055cf9a88c1a5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#61 0x000055cf9a08f803
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x344f803)
#62 0x000055cf9a88e25e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c4e25e)
#63 0x000055cf9a863c9a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c23c9a)
#64 0x000055cf9a8647ef
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c247ef)
#65 0x000055cf9a86dbd5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c2dbd5)
#66 0x000055cf97ddef4e main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x119ef4e)
#67 0x00007fb3795770b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#68 0x000055cf97ec5e5a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x1285e5a)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139
```

gcc and msvc accept the code, but clang ices.

If you change the line

```
using value_type = decltype(matrix_index{int{}, int{}});
```

with

```
using value_type = decltype(matrix_index<int>{int{}, int{}});
```

the code compiles.

Thank you!

-- 
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/20210819/9ee4fac1/attachment-0001.html>


More information about the llvm-bugs mailing list