[llvm-bugs] [Bug 44938] New: Assertion failure when compiling `new user-defined-type[size]` appearing in constexpr constructor
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 17 07:28:49 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44938
Bug ID: 44938
Summary: Assertion failure when compiling `new
user-defined-type[size]` appearing in constexpr
constructor
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: david at doublewise.net
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
The following code:
```
struct a {};
struct b {
constexpr explicit b(int size) {
new a[size];
}
};
auto const x = b(1);
```
when compiled with clang 10 / trunk causes clang to crash with:
```
clang++: /home/david.stone/code/llvm/clang/lib/AST/ExprConstant.cpp:8719: bool
(anonymous namespace)::PointerExprEvaluator::VisitCXXNewExpr(const
clang::CXXNewExpr *): Assertion `CAT && "unexpected type for array
initializer"' failed.
Stack dump:
0. Program arguments: clang++ -std=c++2a -stdlib=libc++ -o /dev/null -c
main.cpp
1. main.cpp:9:20: current parser token ';'
#0 0x0000000001877bf4 PrintStackTraceSignalHandler(void*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x1877bf4)
#1 0x000000000187578e llvm::sys::RunSignalHandlers()
(/home/david.stone/code/llvm/build/bin/clang-10+0x187578e)
#2 0x0000000001876d82 llvm::sys::CleanupOnSignal(unsigned long)
(/home/david.stone/code/llvm/build/bin/clang-10+0x1876d82)
#3 0x00000000018046c3 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
(/home/david.stone/code/llvm/build/bin/clang-10+0x18046c3)
#4 0x00000000018047fc CrashRecoverySignalHandler(int)
(/home/david.stone/code/llvm/build/bin/clang-10+0x18047fc)
#5 0x00007fd53a6e78a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#6 0x00007fd539190f47 raise
/usr/src/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#7 0x00007fd5391928b1 abort /usr/src/glibc-2.27/stdlib/abort.c:81:0
#8 0x00007fd53918242a __assert_fail_base
/usr/src/glibc-2.27/assert/assert.c:89:0
#9 0x00007fd5391824a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
#10 0x0000000003bbf481 (anonymous
namespace)::PointerExprEvaluator::VisitCXXNewExpr(clang::CXXNewExpr const*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3bbf481)
#11 0x0000000003ba1aaf Evaluate(clang::APValue&, (anonymous
namespace)::EvalInfo&, clang::Expr const*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3ba1aaf)
#12 0x0000000003bcdd50 EvaluateStmt((anonymous namespace)::StmtResult&,
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3bcdd50)
#13 0x0000000003bcd628 EvaluateStmt((anonymous namespace)::StmtResult&,
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3bcd628)
#14 0x0000000003c1aee6 HandleConstructorCall(clang::Expr const*, (anonymous
namespace)::LValue const&, clang::APValue*, clang::CXXConstructorDecl const*,
(anonymous namespace)::EvalInfo&, clang::APValue&)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3c1aee6)
#15 0x0000000003ba82a4 HandleConstructorCall(clang::Expr const*, (anonymous
namespace)::LValue const&, llvm::ArrayRef<clang::Expr const*>,
clang::CXXConstructorDecl const*, (anonymous namespace)::EvalInfo&,
clang::APValue&) (/home/david.stone/code/llvm/build/bin/clang-10+0x3ba82a4)
#16 0x0000000003c119bd (anonymous
namespace)::RecordExprEvaluator::VisitCXXConstructExpr(clang::CXXConstructExpr
const*, clang::QualType)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3c119bd)
#17 0x0000000003ba16b3 EvaluateInPlace(clang::APValue&, (anonymous
namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr
const*, bool) (/home/david.stone/code/llvm/build/bin/clang-10+0x3ba16b3)
#18 0x0000000003ba32f9 clang::Expr::EvaluateAsInitializer(clang::APValue&,
clang::ASTContext const&, clang::VarDecl const*,
llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const
(/home/david.stone/code/llvm/build/bin/clang-10+0x3ba32f9)
#19 0x0000000003b0e6dd
clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const
(/home/david.stone/code/llvm/build/bin/clang-10+0x3b0e6dd)
#20 0x0000000003b0e640 clang::VarDecl::evaluateValue() const
(/home/david.stone/code/llvm/build/bin/clang-10+0x3b0e640)
#21 0x00000000039fbf91 clang::ASTContext::DeclMustBeEmitted(clang::Decl const*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x39fbf91)
#22 0x000000000322ff3f
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x322ff3f)
#23 0x000000000322e15a clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool) (/home/david.stone/code/llvm/build/bin/clang-10+0x322e15a)
#24 0x0000000003029f9f
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3029f9f)
#25 0x00000000030279e6 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x30279e6)
#26 0x000000000300b442
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/david.stone/code/llvm/build/bin/clang-10+0x300b442)
#27 0x000000000300ae85
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/david.stone/code/llvm/build/bin/clang-10+0x300ae85)
#28 0x0000000003009f50
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3009f50)
#29 0x0000000003007d46
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/david.stone/code/llvm/build/bin/clang-10+0x3007d46)
#30 0x00000000030030a8 clang::ParseAST(clang::Sema&, bool, bool)
(/home/david.stone/code/llvm/build/bin/clang-10+0x30030a8)
#31 0x000000000203b3f0 clang::FrontendAction::Execute()
(/home/david.stone/code/llvm/build/bin/clang-10+0x203b3f0)
#32 0x0000000001fd1fe4
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/david.stone/code/llvm/build/bin/clang-10+0x1fd1fe4)
#33 0x00000000020ec44f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/david.stone/code/llvm/build/bin/clang-10+0x20ec44f)
#34 0x00000000008bc6fd cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/david.stone/code/llvm/build/bin/clang-10+0x8bc6fd)
#35 0x00000000008ba75c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/david.stone/code/llvm/build/bin/clang-10+0x8ba75c)
#36 0x0000000001e90242 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::$_1>(long)
(/home/david.stone/code/llvm/build/bin/clang-10+0x1e90242)
#37 0x00000000018045e1
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/david.stone/code/llvm/build/bin/clang-10+0x18045e1)
#38 0x0000000001e8f86d
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/home/david.stone/code/llvm/build/bin/clang-10+0x1e8f86d)
#39 0x0000000001e5e88d
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/david.stone/code/llvm/build/bin/clang-10+0x1e5e88d)
#40 0x0000000001e5ec7d
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/home/david.stone/code/llvm/build/bin/clang-10+0x1e5ec7d)
#41 0x0000000001e761d8
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/home/david.stone/code/llvm/build/bin/clang-10+0x1e761d8)
#42 0x00000000008b9f21 main
(/home/david.stone/code/llvm/build/bin/clang-10+0x8b9f21)
#43 0x00007fd539173b97 __libc_start_main
/usr/src/glibc-2.27/csu/../csu/libc-start.c:344:0
#44 0x00000000008b748a _start
(/home/david.stone/code/llvm/build/bin/clang-10+0x8b748a)
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david.stone/code/llvm/build/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-10: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-10: note: diagnostic msg: /tmp/main-7dbff4.cpp
clang-10: note: diagnostic msg: /tmp/main-7dbff4.sh
clang-10: note: diagnostic msg:
********************
```
--
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/20200217/f6730f14/attachment-0001.html>
More information about the llvm-bugs
mailing list