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

VarDecl::checkInitIsIce() !Init->isValueDependent Assertion failure #26508

Closed
llvmbot opened this issue Jan 13, 2016 · 8 comments
Closed

VarDecl::checkInitIsIce() !Init->isValueDependent Assertion failure #26508

llvmbot opened this issue Jan 13, 2016 · 8 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 13, 2016

Bugzilla Link 26134
Resolution FIXED
Resolved on Apr 26, 2018 09:03
Version trunk
OS Linux
Blocks #26433
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@DimitryAndric,@emaste,@zygoloid

Extended Description

This looks quite similar to these bugs, but they have been marked fixed for a while. So this is either a regression, or a new code path.

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

The following code and command line results in an assertion failure at inside a debug copy of trunk:

clang++ orig.ii -std=gnu++11

template<typename GebpKernel, bool UseRotatingKernel = GebpKernel::UseRotatingKernel>
struct PossiblyRotatingKernelHelper {};

template struct gebp_kernel {
void f() { PossiblyRotatingKernelHelper<gebp_kernel> possiblyRotatingKernelHelper; }
static const bool UseRotatingKernel = B;
};

clang-3.8: /usr/local/google/home/saugustine/llvm/llvm/tools/clang/lib/AST/Decl.cpp:2181: bool clang::VarDecl::checkInitIsICE() const: Assertion `!Init->isValueDependent()' failed.

....

Incidentally, if I comment out this assertion, an identical one fires very soon after, and if I comment out that one, another identical one fires very soon after.

@DimitryAndric
Copy link
Collaborator

In the FreeBSD ports tree, we are running into the same assertion, during building of the sfcgal port:

cd /wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/src && /usr/bin/c++ -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DCGAL_INTERSECTION_VERSION=1 -DSFCGAL_BUILD_SHARED -DSFCGAL_EXPORTS -I/wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/include -I/wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/patches/CGAL-4.3 -isystem /usr/local/include -O2 -pipe -fstack-protector -fno-strict-aliasing -O2 -pipe -fstack-protector -fno-strict-aliasing -fPIC -o CMakeFiles/SFCGAL.dir/algorithm/connection.cpp.o -c /wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/src/algorithm/connection.cpp
[ 61%] Building CXX object src/CMakeFiles/SFCGAL.dir/algorithm/difference.cpp.o
cd /wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/src && /usr/bin/c++ -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DCGAL_INTERSECTION_VERSION=1 -DSFCGAL_BUILD_SHARED -DSFCGAL_EXPORTS -I/wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/include -I/wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/patches/CGAL-4.3 -isystem /usr/local/include -O2 -pipe -fstack-protector -fno-strict-aliasing -O2 -pipe -fstack-protector -fno-strict-aliasing -fPIC -o CMakeFiles/SFCGAL.dir/algorithm/difference.cpp.o -c /wrkdirs/usr/ports/databases/sfcgal/work/SFCGAL-1.1.0/src/algorithm/difference.cpp
Assertion failed: (!Init->isValueDependent()), function checkInitIsICE, file /poudriere/jails/headamd64#206074 /usr/src/lib/clang/libclangast/../../../contrib/llvm/tools/clang/lib/AST/Decl.cpp, line 2231.
c++: error: unable to execute command: Abort trap (core dumped)

Etc. I am attempting to minimize the test case, but I assume it look similar to your example, which also results in the same assertion for me, both with the 3.8 release branch, and with trunk r257999.

[1] http://package18.nyi.freebsd.org/data/headamd64#206074 -default/2016-01-15_15h26m58s/logs/errors/sfcgal-1.1.0.log

@DimitryAndric
Copy link
Collaborator

Bisection shows that this problem has been introduced with r253590 ("Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults") by Faisal Vali.

Since the commit message says there should be no functionality change, maybe this is something latent that was now exposed by the change? Or is it really caused by the change itself? Faisal or Richard, any comments?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 19, 2016

Hmm - I'll take a look at it later today - thanks for looping me in - sorry about this.

@DimitryAndric
Copy link
Collaborator

Backtrace:

#​0 0x0000000807aeab3a in thr_kill () from /lib/libc.so.7
#​1 0x0000000807aeab0b in __raise (s=6) at /share/dim/src/freebsd/base/projects/clang380-import/lib/libc/gen/raise.c:52
#​2 0x0000000807aeaa79 in abort () at /share/dim/src/freebsd/base/projects/clang380-import/lib/libc/stdlib/abort.c:65
#​3 0x0000000807b68531 in assert (func=0xffffffff81bc0ef8 <error: Cannot access memory at address 0xffffffff81bc0ef8>, file=0xffffffff81891d18 <error: Cannot access memory at address 0xffffffff81891d18>, line=-2118066604, failedexpr=) at /share/dim/src/freebsd/base/projects/clang380-import/lib/libc/gen/assert.c:51
#​4 0x0000000004fe084d in clang::VarDecl::checkInitIsICE (this=0x8083c0758) at /share/dim/src/llvm/trunk/tools/clang/lib/AST/Decl.cpp:2231
#​5 0x00000000043d39db in clang::IsVariableAConstantExpression (Var=0x8083c0758, Context=...) at /share/dim/src/llvm/trunk/tools/clang/include/clang/Sema/SemaInternal.h:48
#​6 0x000000000433b793 in DoMarkVarDeclReferenced (SemaRef=..., Loc=..., Var=0x8083c0758, E=0x8083c0880) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:13542
#​7 0x000000000433b884 in MarkExprReferenced (SemaRef=..., Loc=..., D=0x8083c0758, E=0x8083c0880, OdrUse=true) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:13562
#​8 0x00000000043046a5 in clang::Sema::MarkDeclRefReferenced (this=0x8082f8000, E=0x8083c0880) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:13600
#​9 0x000000000430442d in clang::Sema::BuildDeclRefExpr (this=0x8082f8000, D=0x8083c0758, Ty=..., VK=clang::VK_LValue, NameInfo=..., SS=0x7fffffff31a8, FoundD=0x8083c0758, TemplateArgs=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:1712
#​10 0x0000000004309dea in clang::Sema::BuildDeclarationNameExpr (this=0x8082f8000, SS=..., NameInfo=..., D=0x8083c0758, FoundD=0x8083c0758, TemplateArgs=0x0, AcceptInvalidDecl=false) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:2974
#​11 0x0000000004308065 in clang::Sema::BuildDeclarationNameExpr (this=0x8082f8000, SS=..., R=..., NeedsADL=false, AcceptInvalidDecl=false) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:2742
#​12 0x000000000448a986 in clang::Sema::BuildPossibleImplicitMemberExpr (this=0x8082f8000, SS=..., TemplateKWLoc=..., R=..., TemplateArgs=0x0, S=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExprMember.cpp:259
#​13 0x0000000004308825 in clang::Sema::BuildQualifiedDeclarationNameExpr (this=0x8082f8000, SS=..., NameInfo=..., IsAddressOfOperand=false, S=0x0, RecoveryTSI=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaExpr.cpp:2349
#​14 0x00000000047a3b4a in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::RebuildDependentScopeDeclRefExpr (this=0x7fffffff3910, QualifierLoc=..., TemplateKWLoc=..., NameInfo=..., TemplateArgs=0x0, IsAddressOfOperand=false, RecoveryTSI=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/TreeTransform.h:2600
#​15 0x00000000047a38e0 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr (this=0x7fffffff3910, E=0x8082f6d58, IsAddressOfOperand=false, RecoveryTSI=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/TreeTransform.h:9713
#​16 0x0000000004795203 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr (this=0x7fffffff3910, E=0x8082f6d58) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/TreeTransform.h:9679
#​17 0x000000000478a2d4 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr (this=0x7fffffff3910, E=0x8082f6d58) at tools/clang/include/clang/AST/StmtNodes.inc:465
#​18 0x0000000004783dfe in clang::Sema::SubstExpr (this=0x8082f8000, E=0x8082f6d58, TemplateArgs=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:2655
#​19 0x000000000469b3e3 in SubstDefaultTemplateArgument (SemaRef=..., Template=0x8082f6eb0, TemplateLoc=..., RAngleLoc=..., Param=0x8082f6da8, Converted=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaTemplate.cpp:3287
#​20 0x0000000004694bd6 in clang::Sema::CheckTemplateArgumentList (this=0x8082f8000, Template=0x8082f6eb0, TemplateLoc=..., TemplateArgs=..., PartialTemplateArgs=false, Converted=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaTemplate.cpp:3914
#​21 0x000000000469357f in clang::Sema::CheckTemplateIdType (this=0x8082f8000, Name=..., TemplateLoc=..., TemplateArgs=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaTemplate.cpp:2107
#​22 0x0000000004695b69 in clang::Sema::ActOnTemplateIdType (this=0x8082f8000, SS=..., TemplateKWLoc=..., TemplateD=..., TemplateLoc=..., LAngleLoc=..., TemplateArgsIn=..., RAngleLoc=..., IsCtorOrDtorName=false) at /share/dim/src/llvm/trunk/tools/clang/lib/Sema/SemaTemplate.cpp:2277
#​23 0x0000000003d5dede in clang::Parser::AnnotateTemplateIdTokenAsType (this=0x8082a1200) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseTemplate.cpp:1055
#​24 0x0000000003c9444a in clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec (this=0x8082a1200, EnteringContext=false, NeedType=false, SS=..., IsNewScope=true) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/Parser.cpp:1765
#​25 0x0000000003c9324e in clang::Parser::TryAnnotateName (this=0x8082a1200, IsAddressOfOperand=false, CCC=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/Parser.cpp:1404
#​26 0x0000000003d47878 in clang::Parser::ParseStatementOrDeclarationAfterAttributes (this=0x8082a1200, Stmts=..., OnlyStatement=false, TrailingElseLoc=0x0, Attrs=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseStmt.cpp:185
#​27 0x0000000003d46f9d in clang::Parser::ParseStatementOrDeclaration (this=0x8082a1200, Stmts=..., OnlyStatement=false, TrailingElseLoc=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseStmt.cpp:106
#​28 0x0000000003d4e244 in clang::Parser::ParseCompoundStatementBody (this=0x8082a1200, isStmtExpr=false) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseStmt.cpp:968
#​29 0x0000000003d4ed76 in clang::Parser::ParseFunctionStatementBody (this=0x8082a1200, Decl=0x8083c06a0, BodyScope=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseStmt.cpp:1914
#​30 0x0000000003ca18ee in clang::Parser::ParseLexedMethodDef (this=0x8082a1200, LM=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:554
#​31 0x0000000003ca1334 in clang::Parser::LexedMethod::ParseLexedMethodDefs (this=0x8082a9280) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:256
#​32 0x0000000003ca005e in clang::Parser::ParseLexedMethodDefs (this=0x8082a1200, Class=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:483
#​33 0x0000000003cd7c40 in clang::Parser::ParseCXXMemberSpecification (this=0x8082a1200, RecordLoc=..., AttrFixitLoc=..., Attrs=..., TagType=17, TagDecl=0x8083c0318) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseDeclCXX.cpp:3116
#​34 0x0000000003cd6313 in clang::Parser::ParseClassSpecifier (this=0x8082a1200, TagTokKind=clang::tok::TokenKind::kw_struct, StartLoc=..., DS=..., TemplateInfo=..., AS=clang::AS_none, EnteringContext=true, DSC=clang::Parser::DSC_top_level, Attributes=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseDeclCXX.cpp:1760
#​35 0x0000000003cb39af in clang::Parser::ParseDeclarationSpecifiers (this=0x8082a1200, DS=..., TemplateInfo=..., AS=clang::AS_none, DSContext=clang::Parser::DSC_top_level, LateAttrs=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseDecl.cpp:3355
#​36 0x0000000003d5a244 in clang::Parser::ParseSingleDeclarationAfterTemplate (this=0x8082a1200, Context=0, TemplateInfo=..., DiagsFromTParams=..., DeclEnd=..., AS=clang::AS_none, AccessAttrs=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseTemplate.cpp:206
#​37 0x0000000003d59da5 in clang::Parser::ParseTemplateDeclarationOrSpecialization (this=0x8082a1200, Context=0, DeclEnd=..., AS=clang::AS_none, AccessAttrs=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseTemplate.cpp:151
#​38 0x0000000003d59765 in clang::Parser::ParseDeclarationStartingWithTemplate (this=0x8082a1200, Context=0, DeclEnd=..., AS=clang::AS_none, AccessAttrs=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseTemplate.cpp:39
#​39 0x0000000003cb005b in clang::Parser::ParseDeclaration (this=0x8082a1200, Context=0, DeclEnd=..., attrs=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseDecl.cpp:1461
#​40 0x0000000003c904cd in clang::Parser::ParseExternalDeclaration (this=0x8082a1200, attrs=..., DS=0x0) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/Parser.cpp:743
#​41 0x0000000003c8fa09 in clang::Parser::ParseTopLevelDecl (this=0x8082a1200, Result=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/Parser.cpp:593
#​42 0x0000000003c89019 in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=false) at /share/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseAST.cpp:161
#​43 0x0000000002be12a5 in clang::ASTFrontendAction::ExecuteAction (this=0x8082a60c0) at /share/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:538
#​44 0x00000000030ec65c in clang::CodeGenAction::ExecuteAction (this=0x8082a60c0) at /share/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenAction.cpp:791
#​45 0x0000000002be08d0 in clang::FrontendAction::Execute (this=0x8082a60c0) at /share/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:439
#​46 0x0000000002b5c888 in clang::CompilerInstance::ExecuteAction (this=0x808298000, Act=...) at /share/dim/src/llvm/trunk/tools/clang/lib/Frontend/CompilerInstance.cpp:840
#​47 0x0000000002d460c2 in clang::ExecuteCompilerInvocation (Clang=0x808298000) at /share/dim/src/llvm/trunk/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222
#​48 0x000000000084a194 in cc1_main (Argv=..., Argv0=0x7fffffffe7d8 "/home/dim/obj/llvm-257322M-trunk-freebsd11-amd64-ninja-dbg-1/bin/clang", MainAddr=0x8380a0 <GetExecutablePath(char const*, bool)>) at /share/dim/src/llvm/trunk/tools/clang/tools/driver/cc1_main.cpp:116
#​49 0x000000000083af36 in ExecuteCC1Tool (argv=..., Tool=...) at /share/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:301
#​50 0x0000000000838d64 in main (argc
=6, argv
=0x7fffffffe520) at /share/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:366

In frame 4, local variables 'Eval' and 'Init' variable look like this:

(gdb) frame 4
#​4 0x0000000004fe084d in clang::VarDecl::checkInitIsICE (this=0x8083c0758) at /share/dim/src/llvm/trunk/tools/clang/lib/AST/Decl.cpp:2231
2231 assert(!Init->isValueDependent());
(gdb) print *Eval
$2 = {WasEvaluated = false, IsEvaluating = false, CheckedICE = false, CheckingICE = false, IsICE = false, Value = 0x8083c07b8, Evaluated = {Kind = clang::APValue::Uninitialized, static DataSize = 48, Data = {<llvm::AlignedCharArray<8, 48>> = {buffer = '\245' <repeats 48 times>}, }}}
(gdb) print *Init
$1 = {clang::Stmt = {{StmtBits = {sClass = 64}, CompoundStmtBits = {NumStmts = 10854496}, ExprBits = {ValueKind = 0, ObjectKind = 0, TypeDependent = 0, ValueDependent = 1, InstantiationDependent = 1, ContainsUnexpandedParameterPack = 0}, CharacterLiteralBits = {Kind = 0}, FloatingLiteralBits = {Semantics = 0, IsExact = 0}, UnaryExprOrTypeTraitExprBits = {Kind = 0, IsType = 0}, DeclRefExprBits = {HasQualifier = 0, HasTemplateKWAndArgsInfo = 0, HasFoundDecl = 0, HadMultipleCandidates = 0, RefersToEnclosingVariableOrCapture = 0}, CastExprBits = {Kind = 32, BasePathSize = 662}, CallExprBits = {NumPreArgs = 0}, ExprWithCleanupsBits = {NumObjects = 42400}, PseudoObjectExprBits = {NumSubExprs = 160, ResultIndex = 165}, ObjCIndirectCopyRestoreExprBits = {ShouldCopy = 0}, InitListExprBits = {HadArrayRangeDesignator = 0}, TypeTraitExprBits = {Kind = 160, Value = 1, NumArgs = 82}}, static StatisticsEnabled = false}, TR = {Value = {Value = 34497061696}}}

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 19, 2016

Should be fixed by r258110
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147211.html

Let me know if something else emerges related to this.

@DimitryAndric
Copy link
Collaborator

Should be fixed by r258110
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147211.html

Let me know if something else emerges related to this.

Thanks Faisal. I can confirm that r258110 fixes both the test case from saugustine@google.com, and my test case.

This change should be merged to the 3.8 branch, I will notify Hans Wennborg.

@DimitryAndric
Copy link
Collaborator

*** Bug llvm/llvm-bugzilla-archive#37247 has been marked as a duplicate of this bug. ***

@DimitryAndric
Copy link
Collaborator

mentioned in issue llvm/llvm-bugzilla-archive#37247

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

2 participants