[llvm-bugs] [Bug 45133] New: ICE with union member change in constexpr during function call to initialize union member

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 5 20:01:51 PST 2020


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

            Bug ID: 45133
           Summary: ICE with union member change in constexpr during
                    function call to initialize union member
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following case, which (during constant expression evaluation) starts the
lifetime of a union member while evaluating a function whose return value would
become the other union member leads to an ICE.

### SOURCE (<stdin>):
struct A { long x; };

union U;
constexpr A foo(U *up);

union U {
  A a = foo(this); int y;
};

constexpr A foo(U *up) {
  up->y = 11;
  return {42};
}

extern constexpr U u = {};


### COMPILER INVOCATION:
clang -cc1 -fsyntax-only -xc++ -std=c++2a -


### COMPILER OUTPUT:
Stack dump:
0.      Program arguments: /opt/wandbox/clang-head/bin/clang -cc1 -fsyntax-only
-xc++ -std=c++2a -
1.      <stdin>:15:26: current parser token ';'
 #0 0x00000000020ee7b4 PrintStackTraceSignalHandler(void*)
(/opt/wandbox/clang-head/bin/clang+0x20ee7b4)
 #1 0x00000000020ec4ae llvm::sys::RunSignalHandlers()
(/opt/wandbox/clang-head/bin/clang+0x20ec4ae)
 #2 0x00000000020eebac SignalHandler(int)
(/opt/wandbox/clang-head/bin/clang+0x20eebac)
 #3 0x00007fa5906e6390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x0000000003d56060 clang::APValue::swap(clang::APValue&)
(/opt/wandbox/clang-head/bin/clang+0x3d56060)
 #5 0x0000000003f3005d (anonymous
namespace)::IntExprEvaluator::Success(llvm::APInt const&, clang::Expr const*)
(/opt/wandbox/clang-head/bin/clang+0x3f3005d)
 #6 0x0000000003f10c27 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*)
(/opt/wandbox/clang-head/bin/clang+0x3f10c27)
 #7 0x0000000003f313a0 (anonymous
namespace)::IntExprEvaluator::VisitCastExpr(clang::CastExpr const*)
(/opt/wandbox/clang-head/bin/clang+0x3f313a0)
 #8 0x0000000003ee6269 Evaluate(clang::APValue&, (anonymous
namespace)::EvalInfo&, clang::Expr const*)
(/opt/wandbox/clang-head/bin/clang+0x3ee6269)
 #9 0x0000000003ee6016 EvaluateInPlace(clang::APValue&, (anonymous
namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr
const*, bool) (/opt/wandbox/clang-head/bin/clang+0x3ee6016)
#10 0x0000000003f40917 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::RecordExprEvaluator, bool>::Visit(clang::Stmt const*)
(/opt/wandbox/clang-head/bin/clang+0x3f40917)
#11 0x0000000003ee6094 EvaluateInPlace(clang::APValue&, (anonymous
namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr
const*, bool) (/opt/wandbox/clang-head/bin/clang+0x3ee6094)
#12 0x0000000003f05c47 EvaluateStmt((anonymous namespace)::StmtResult&,
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*)
(/opt/wandbox/clang-head/bin/clang+0x3f05c47)
#13 0x0000000003f05655 EvaluateStmt((anonymous namespace)::StmtResult&,
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*)
(/opt/wandbox/clang-head/bin/clang+0x3f05655)
#14 0x0000000003eeb78d HandleFunctionCall(clang::SourceLocation,
clang::FunctionDecl const*, (anonymous namespace)::LValue const*,
llvm::ArrayRef<clang::Expr const*>, clang::Stmt const*, (anonymous
namespace)::EvalInfo&, clang::APValue&, (anonymous namespace)::LValue const*)
(/opt/wandbox/clang-head/bin/clang+0x3eeb78d)
#15 0x0000000003f464c6 (anonymous namespace)::ExprEvaluatorBase<(anonymous
namespace)::RecordExprEvaluator>::handleCallExpr(clang::CallExpr const*,
clang::APValue&, (anonymous namespace)::LValue const*)
(/opt/wandbox/clang-head/bin/clang+0x3f464c6)
#16 0x0000000003f3fd0e clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::RecordExprEvaluator, bool>::Visit(clang::Stmt const*)
(/opt/wandbox/clang-head/bin/clang+0x3f3fd0e)
#17 0x0000000003ee6094 EvaluateInPlace(clang::APValue&, (anonymous
namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr
const*, bool) (/opt/wandbox/clang-head/bin/clang+0x3ee6094)
#18 0x0000000003f400c0 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::RecordExprEvaluator, bool>::Visit(clang::Stmt const*)
(/opt/wandbox/clang-head/bin/clang+0x3f400c0)
#19 0x0000000003ee6094 EvaluateInPlace(clang::APValue&, (anonymous
namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr
const*, bool) (/opt/wandbox/clang-head/bin/clang+0x3ee6094)
#20 0x0000000003ee74b3 clang::Expr::EvaluateAsInitializer(clang::APValue&,
clang::ASTContext const&, clang::VarDecl const*,
llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const
(/opt/wandbox/clang-head/bin/clang+0x3ee74b3)
#21 0x0000000003e5f6f6
clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const
(/opt/wandbox/clang-head/bin/clang+0x3e5f6f6)
#22 0x00000000036ce0bd
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
(/opt/wandbox/clang-head/bin/clang+0x36ce0bd)
#23 0x00000000036cc565 clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool) (/opt/wandbox/clang-head/bin/clang+0x36cc565)
#24 0x00000000034e6b9f
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/wandbox/clang-head/bin/clang+0x34e6b9f)
#25 0x00000000034e43c7 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/wandbox/clang-head/bin/clang+0x34e43c7)
#26 0x00000000034ca2b8
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/wandbox/clang-head/bin/clang+0x34ca2b8)
#27 0x00000000034c9d35
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/opt/wandbox/clang-head/bin/clang+0x34c9d35)
#28 0x00000000034c8e8b
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/opt/wandbox/clang-head/bin/clang+0x34c8e8b)
#29 0x00000000034c6f87
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/wandbox/clang-head/bin/clang+0x34c6f87)
#30 0x00000000034c2288 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/wandbox/clang-head/bin/clang+0x34c2288)
#31 0x00000000027d5202 clang::FrontendAction::Execute()
(/opt/wandbox/clang-head/bin/clang+0x27d5202)
#32 0x000000000276f7df
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/wandbox/clang-head/bin/clang+0x276f7df)
#33 0x0000000002873d3c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/wandbox/clang-head/bin/clang+0x2873d3c)
#34 0x000000000091bbd5 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/wandbox/clang-head/bin/clang+0x91bbd5)
#35 0x0000000000919ffb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/wandbox/clang-head/bin/clang+0x919ffb)
#36 0x000000000091984d main (/opt/wandbox/clang-head/bin/clang+0x91984d)
#37 0x00007fa58f1d8830 __libc_start_main
/build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#38 0x0000000000916ca9 _start (/opt/wandbox/clang-head/bin/clang+0x916ca9)


### COMPILER VERSION INFO (clang -v):
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
e6d9b2cb92dd8ad544f43dc97e82fa98e07e977c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

-- 
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/20200306/77fd4267/attachment-0001.html>


More information about the llvm-bugs mailing list