[llvm-bugs] [Bug 26793] New: Assertion failure in return statement for a type with fold expression that contains two parameter packs in a function template of a class template

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 1 12:56:39 PST 2016


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

            Bug ID: 26793
           Summary: Assertion failure in return statement for a type with
                    fold expression that contains two parameter packs in a
                    function template of a class template
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code gives an assertion failure with clang 3.7 and trunk. The
failure is gone if you comment out fails1 and fails2.

template<typename, typename>
constexpr auto value = true;

template<typename... Types>
struct s {
    template<typename... Args, bool = (... and value<Types, Args>)>
    s(Args...)
    {
    }
};


s<> works() {
    return {};
}

s<> fails1() {
    return s<>{};
}

s<> fails2() {
    s<> v;
    return v;
}






#0 0x000000000148c148 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/david/ssd2/llvm/lib/Support/Unix/Signals.inc:323:7
#1 0x000000000148aba6 bool __gnu_cxx::operator!=<std::pair<void (*)(void*),
void*>*, std::vector<std::pair<void (*)(void*), void*>,
std::allocator<std::pair<void (*)(void*), void*> > >
>(__gnu_cxx::__normal_iterator<std::pair<void (*)(void*), void*>*,
std::vector<std::pair<void (*)(void*), void*>, std::allocator<std::pair<void
(*)(void*), void*> > > > const&, __gnu_cxx::__normal_iterator<std::pair<void
(*)(void*), void*>*, std::vector<std::pair<void (*)(void*), void*>,
std::allocator<std::pair<void (*)(void*), void*> > > > const&)
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/bits/stl_iterator.h:844:27
#2 0x000000000148aba6 llvm::sys::RunSignalHandlers()
/home/david/ssd2/llvm/lib/Support/Signals.cpp:44:0
#3 0x000000000148c63c SignalHandler(int)
/home/david/ssd2/llvm/lib/Support/Unix/Signals.inc:200:3
#4 0x00007f6d9c3d3cb0 (/lib64/libpthread.so.0+0x10cb0)
#5 0x0000000002280747 getPackSubstitutedTemplateArgument(clang::Sema&,
clang::TemplateArgument)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:856:7
#6 0x0000000002280747 (anonymous
namespace)::TemplateInstantiator::TransformSubstTemplateTypeParmPackType(clang::TypeLocBuilder&,
clang::SubstTemplateTypeParmPackTypeLoc)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:1412:0
#7 0x0000000002280747 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc)
/home/david/ssd2/llvm/tools/clang/include/clang/AST/TypeNodes.def:97:0
#8 0x000000000227e678 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*)
/home/david/ssd2/llvm/tools/clang/lib/Sema/TreeTransform.h:3914:21
#9 0x0000000002296a0a clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc
const&, clang::TemplateArgumentLoc&, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/TreeTransform.h:3650:10
#10 0x000000000229ffa5 bool clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc
const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*,
clang::TemplateArgumentListInfo&, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/TreeTransform.h:3869:9
#11 0x000000000229208d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformUnresolvedLookupExpr(clang::UnresolvedLookupExpr*)
/home/david/ssd2/llvm/tools/clang/lib/Sema/TreeTransform.h:9538:7
#12 0x000000000228d32c clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXFoldExpr(clang::CXXFoldExpr*)
/home/david/ssd2/llvm/tools/clang/lib/Sema/TreeTransform.h:10606:22
#13 0x0000000002284431 clang::Sema::SubstExpr(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:2655:10
#14 0x000000000221c25e SubstDefaultTemplateArgument(clang::Sema&,
clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation,
clang::NonTypeTemplateParmDecl*,
llvm::SmallVectorImpl<clang::TemplateArgument>&)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplate.cpp:3283:10
#15 0x000000000221bdfa clang::ActionResult<clang::Expr*, true>::isInvalid()
const /home/david/ssd2/llvm/tools/clang/include/clang/Sema/Ownership.h:199:37
#16 0x000000000221bdfa
clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*,
clang::SourceLocation, clang::SourceLocation, clang::Decl*,
llvm::SmallVectorImpl<clang::TemplateArgument>&, bool&)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplate.cpp:3390:0
#17 0x0000000002255a2a
clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*,
llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&,
llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplateDeduction.cpp:2858:9
#18 0x0000000002257abc
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaTemplateDeduction.cpp:3494:10
#19 0x00000000021b8c9d
clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::TemplateArgumentListInfo*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaOverload.cpp:6307:11
#20 0x0000000002130d2e ResolveConstructorOverload(clang::Sema&,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&, clang::DeclContextLookupResult,
clang::OverloadCandidate*&, bool, bool, bool, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaInit.cpp:3396:9
#21 0x0000000002121731 TryConstructorInitialization(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType,
clang::InitializationSequence&, bool, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaInit.cpp:3500:14
#22 0x000000000211f743
clang::InitializationSequence::InitializeFrom(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaInit.cpp:5012:7
#23 0x000000000212e537
clang::Sema::PerformCopyInitialization(clang::InitializedEntity const&,
clang::SourceLocation, clang::ActionResult<clang::Expr*, true>, bool, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaInit.cpp:7687:23
#24 0x00000000021ec7c8
clang::Sema::PerformMoveOrCopyInitialization(clang::InitializedEntity const&,
clang::VarDecl const*, clang::QualType, clang::Expr*, bool)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2830:11
#25 0x00000000021ee665 clang::Sema::BuildReturnStmt(clang::SourceLocation,
clang::Expr*) /home/david/ssd2/llvm/tools/clang/lib/Sema/SemaStmt.cpp:3320:24
#26 0x00000000021edf99 clang::Sema::ActOnReturnStmt(clang::SourceLocation,
clang::Expr*, clang::Scope*)
/home/david/ssd2/llvm/tools/clang/lib/Sema/SemaStmt.cpp:3134:18
#27 0x0000000001db6545 clang::Parser::ParseReturnStatement()
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1882:10
#28 0x0000000001db19de
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseStmt.cpp:267:11
#29 0x0000000001db131d
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseStmt.cpp:113:20
#30 0x0000000001db7cf4 clang::Parser::ParseCompoundStatementBody(bool)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseStmt.cpp:987:11
#31 0x0000000001db84c6 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1936:21
#32 0x0000000001d425c0
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
/home/david/ssd2/llvm/tools/clang/lib/Parse/Parser.cpp:1157:10
#33 0x0000000001d56753 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseDecl.cpp:1775:16
#34 0x0000000001d41d69
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/home/david/ssd2/llvm/tools/clang/lib/Parse/Parser.cpp:937:10
#35 0x0000000001d41738
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/home/david/ssd2/llvm/tools/clang/lib/Parse/Parser.cpp:953:12
#36 0x0000000001d407c8
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/home/david/ssd2/llvm/tools/clang/lib/Parse/Parser.cpp:805:12
#37 0x0000000001d4007a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
/home/david/ssd2/llvm/tools/clang/lib/Parse/Parser.cpp:594:10
#38 0x0000000001d3cc36 clang::ParseAST(clang::Sema&, bool, bool)
/home/david/ssd2/llvm/tools/clang/lib/Parse/ParseAST.cpp:161:5
#39 0x000000000181f44c clang::FrontendAction::Execute()
/home/david/ssd2/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:443:7
#40 0x00000000017efc68
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/david/ssd2/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:841:7
#41 0x000000000188bc0e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/david/ssd2/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:227:18
#42 0x00000000007638ea cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/david/ssd2/llvm/tools/clang/tools/driver/cc1_main.cpp:116:13
#43 0x0000000000762953 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/home/david/ssd2/llvm/tools/clang/tools/driver/driver.cpp:301:12
#44 0x0000000000762953 main
/home/david/ssd2/llvm/tools/clang/tools/driver/driver.cpp:366:0
#45 0x00007f6d9b59b5a0 __libc_start_main
/var/tmp/portage/sys-libs/glibc-2.22-r2/work/glibc-2.22/csu/libc-start.c:323:0
#46 0x000000000075fd99 _start
(/home/david/ssd2/llvm-obj/bin/clang-3.9+0x75fd99)
Stack dump:
0.    Program arguments: /home/david/ssd2/llvm-obj/bin/clang-3.9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name main.cpp -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -coverage-file
/home/david/test/main.cpp -resource-dir
/home/david/ssd2/llvm-obj/bin/../lib/clang/3.9.0 -internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5 -internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/backward
-internal-isystem /usr/local/include -internal-isystem
/home/david/ssd2/llvm-obj/bin/../lib/clang/3.9.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++1z -fdeprecated-macro -fdebug-compilation-dir /home/david/test
-ferror-limit 19 -fmessage-length 105 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o main.o -x c++
source/main.cpp 
1.    source/main.cpp:18:14: current parser token ';'
2.    source/main.cpp:17:14: parsing function body 'fails1'
3.    source/main.cpp:17:14: in compound statement ('{}')
clang-3.9: error: unable to execute command: Segmentation fault
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 262178) (llvm/trunk 262157)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david/ssd2/llvm-obj/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg: /tmp/main-2bbcb7.cpp
clang-3.9: note: diagnostic msg: /tmp/main-2bbcb7.sh
clang-3.9: note: diagnostic msg: 

********************




Run script:

# Crash reproducer for clang version 3.9.0 (trunk 262178) (llvm/trunk 262157)
# Driver args: "--driver-mode=g++" "-std=c++1z" "-c" "source/main.cpp"
# Original command:  "/home/david/ssd2/llvm-obj/bin/clang-3.9" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "main.cpp" "-mrelocation-model"
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno"
"-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array"
"-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb"
"-coverage-file" "/home/david/test/main.cpp" "-resource-dir"
"/home/david/ssd2/llvm-obj/bin/../lib/clang/3.9.0" "-internal-isystem"
"/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5" "-internal-isystem"
"/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/x86_64-pc-linux-gnu"
"-internal-isystem"
"/usr/lib64/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/backward"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/home/david/ssd2/llvm-obj/bin/../lib/clang/3.9.0/include"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-std=c++1z" "-fdeprecated-macro" "-fdebug-compilation-dir"
"/home/david/test" "-ferror-limit" "19" "-fmessage-length" "105"
"-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "main.o" "-x" "c++"
"source/main.cpp"
 "/home/david/ssd2/llvm-obj/bin/clang-3.9" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "main.cpp" "-mrelocation-model"
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno"
"-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array"
"-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-std=c++1z"
"-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "105"
"-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "main-2bbcb7.cpp"

-- 
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/20160301/d49ab06c/attachment-0001.html>


More information about the llvm-bugs mailing list