LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 44919 - Assertion `!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"' failed.
Summary: Assertion `!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"' ...
Status: RESOLVED DUPLICATE of bug 45468
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-14 14:38 PST by Jordan Rupprecht
Modified: 2020-04-12 03:53 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jordan Rupprecht 2020-02-14 14:38:49 PST
This assertion is failing for me at head with this reduced repro (using a debug build of clang):

$ cat repro.cc 
template <typename>
class b {
  __attribute__((target("avx"))) void c();
};
class B {
 public:
  __attribute__((target("avx"))) __attribute__((always_inline)) B();
};
template <typename d>
void b<d>::c() {
  B a;
}
template class b<int>;

$ clang++ -c repro.cc
clang++: llvm-project/clang/include/clang/AST/GlobalDecl.h:45: void clang::GlobalDecl::Init(const clang::Decl *): Assertion `!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"' failed.
Stack dump:
0.      Program arguments: clang++ -c repro.cc
1.      repro.cc:13:22: current parser token ';'
2.      repro.cc:3:39: instantiating function definition 'b<int>::c'
3.      repro.cc:3:39: LLVM IR generation of declaration 'b<int>::c'
4.      repro.cc:3:39: Generating code for declaration 'b<int>::c'
 #0 0x0000000007f89b17 llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm-project/llvm/lib/Support/Unix/Signals.inc:564:11
... <irrelevant stack unwinding> ...
#11 0x00000000082d580f clang::GlobalDecl::Init(clang::Decl const*) llvm-project/clang/include/clang/AST/GlobalDecl.h:46:5
#12 0x00000000082ded19 clang::GlobalDecl::GlobalDecl(clang::FunctionDecl const*, unsigned int) llvm-project/clang/include/clang/AST/GlobalDecl.h:57:3
#13 0x0000000008615705 clang::CodeGen::CodeGenFunction::checkTargetFeatures(clang::SourceLocation, clang::FunctionDecl const*) llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:2351:22
#14 0x000000000842a99d clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot, clang::CodeGen::CallArgList const&, llvm::CallBase**, clang::SourceLocation) llvm-project/clang/lib/CodeGen/CGCall.cpp:3977:41
#15 0x00000000085e0d53 clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot, clang::CodeGen::CallArgList const&, llvm::CallBase**) llvm-project/clang/lib/CodeGen/CodeGenFunction.h:3621:12
#16 0x000000000862c70b clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::Address, clang::CodeGen::CallArgList&, clang::CodeGen::AggValueSlot::Overlap_t, clang::SourceLocation, bool) llvm-project/clang/lib/CodeGen/CGClass.cpp:2177:3
#17 0x000000000862be8e clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::AggValueSlot, clang::CXXConstructExpr const*) llvm-project/clang/lib/CodeGen/CGClass.cpp:2094:1
#18 0x00000000087c2e2e clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr const*, clang::CodeGen::AggValueSlot) llvm-project/clang/lib/CodeGen/CGExprCXX.cpp:651:1
#19 0x000000000877dc7e (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1269:1
#20 0x0000000008779b90 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) llvm-build/dev/tools/clang/include/clang/AST/StmtNodes.inc:679:1
#21 0x00000000087777ab (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:107:3
#22 0x00000000087773b4 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1849:1
...
Comment 1 Dimitry Andric 2020-04-12 03:12:39 PDT
Reduced even further to just:

// clang -cc1 -triple x86_64-- -S -target-feature +avx2 shacal2_avx2-min.cpp
class a {
public:
  __attribute__((target("avx2"))) __attribute__((__always_inline__)) a() {}
};
void b() { a c; }

This assertion also happens when building the botan2 software, see:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245550
Comment 2 Dimitry Andric 2020-04-12 03:20:10 PDT
This assertion appears to have been fixed between these commits:

llvmorg-11-init-8226-g4007e5f32e6
llvmorg-11-init-8326-gdb71354e4ff

Bisecting now.
Comment 3 Dimitry Andric 2020-04-12 03:53:29 PDT
This was fixed for bug 45468, in https://reviews.llvm.org/rG30588a739584bb8ac41715d68656d22bd85198e7

*** This bug has been marked as a duplicate of bug 45468 ***