The following code ICEs all known versions of Clang dating back to Clang 3.4 (https://wandbox.org/permlink/HzVyaW9GZcHdNG7g): struct A { int x; }; int main() { [](auto t) -> decltype(decltype(t)::x) { return 0; }(A()); } Clang ICE's when `x` is a member of `decltype(t)`. Oddly, it does not ICE if `x` is not a member of `A`. It also does not ICE if it is not within the trailing return type. e.g. the following does not ICE: struct A { int x; }; int main() { [](auto t) { return decltype(decltype(t)::x)(0); }(A()); } ---- #0 0x00007f68d9bf164b llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/../lib/libLLVM-6.0.so+0x85464b) #1 0x00007f68d9bef33e llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-6.0.so+0x85233e) #2 0x00007f68d9bef5ab (/usr/bin/../lib/libLLVM-6.0.so+0x8525ab) #3 0x00007f68d786e8f0 __restore_rt (/usr/bin/../lib/libc.so.6+0x368f0) #4 0x00007f68d4d3676b clang::Sema::BuildPossibleImplicitMemberExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, clang::TemplateArgumentListInfo const*, clang::Scope const*) (/usr/bin/../lib/../lib/libclangSema.so.6+0x3f676b) #5 0x00007f68d4c99c79 clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool, clang::Scope const*, clang::TypeSourceInfo**) (/usr/bin/../lib/../lib/libclangSema.so.6+0x359c79) #6 0x00007f68d4f3d633 (/usr/bin/../lib/../lib/libclangSema.so.6+0x5fd633) #7 0x00007f68d4f25608 (/usr/bin/../lib/../lib/libclangSema.so.6+0x5e5608) #8 0x00007f68d4f2d05a (/usr/bin/../lib/../lib/libclangSema.so.6+0x5ed05a) #9 0x00007f68d4f41c6b clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, clang::CXXRecordDecl*, unsigned int) (/usr/bin/../lib/../lib/libclangSema.so.6+0x601c6b) #10 0x00007f68d4f4aea4 clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*, llvm::SmallVectorImpl<clang::ParmVarDecl*>&) (/usr/bin/../lib/../lib/libclangSema.so.6+0x60aea4) #11 0x00007f68d4f5cdcb clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*, clang::TemplateParameterList*, bool) (/usr/bin/../lib/../lib/libclangSema.so.6+0x61cdcb) #12 0x00007f68d4f5992b clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/usr/bin/../lib/../lib/libclangSema.so.6+0x61992b) #13 0x00007f68d4f10cdc clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) (/usr/bin/../lib/../lib/libclangSema.so.6+0x5d0cdc) #14 0x00007f68d4f15ead clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/usr/bin/../lib/../lib/libclangSema.so.6+0x5d5ead) #15 0x00007f68d4e26c17 clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool) (/usr/bin/../lib/../lib/libclangSema.so.6+0x4e6c17) #16 0x00007f68d4e27325 clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) (/usr/bin/../lib/../lib/libclangSema.so.6+0x4e7325) #17 0x00007f68d4e39fb3 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/bin/../lib/../lib/libclangSema.so.6+0x4f9fb3) #18 0x00007f68d4ca1be7 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) (/usr/bin/../lib/../lib/libclangSema.so.6+0x361be7) #19 0x00007f68d52cd85a clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/usr/bin/../lib/../lib/libclangParse.so.6+0x6b85a) #20 0x00007f68d52c8124 clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) (/usr/bin/../lib/../lib/libclangParse.so.6+0x66124) #21 0x00007f68d52ca465 clang::Parser::ParseCastExpression(bool, bool, clang::Parser::TypeCastState, bool) (/usr/bin/../lib/../lib/libclangParse.so.6+0x68465) #22 0x00007f68d52cbb3d clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/bin/../lib/../lib/libclangParse.so.6+0x69b3d) #23 0x00007f68d52cc68a clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/bin/../lib/../lib/libclangParse.so.6+0x6a68a) #24 0x00007f68d53102fb clang::Parser::ParseExprStatement() (/usr/bin/../lib/../lib/libclangParse.so.6+0xae2fb) #25 0x00007f68d5311366 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/../lib/../lib/libclangParse.so.6+0xaf366) #26 0x00007f68d53115d6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) (/usr/bin/../lib/../lib/libclangParse.so.6+0xaf5d6) #27 0x00007f68d5315370 clang::Parser::ParseCompoundStatementBody(bool) (/usr/bin/../lib/../lib/libclangParse.so.6+0xb3370) #28 0x00007f68d5317cc8 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/bin/../lib/../lib/libclangParse.so.6+0xb5cc8) #29 0x00007f68d5333577 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/bin/../lib/../lib/libclangParse.so.6+0xd1577) #30 0x00007f68d52aa40b clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/bin/../lib/../lib/libclangParse.so.6+0x4840b) #31 0x00007f68d532d5e3 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/bin/../lib/../lib/libclangParse.so.6+0xcb5e3) #32 0x00007f68d532db82 (/usr/bin/../lib/../lib/libclangParse.so.6+0xcbb82) #33 0x00007f68d53347c1 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/bin/../lib/../lib/libclangParse.so.6+0xd27c1) #34 0x00007f68d5335896 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/bin/../lib/../lib/libclangParse.so.6+0xd3896) #35 0x00007f68d528c113 clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/../lib/../lib/libclangParse.so.6+0x2a113) #36 0x00007f68d8b136e8 clang::CodeGenAction::ExecuteAction() (/usr/bin/../lib/libclangCodeGen.so.6+0x2916e8) #37 0x00007f68d8257f26 clang::FrontendAction::Execute() (/usr/bin/../lib/libclangFrontend.so.6+0xd4f26) #38 0x00007f68d82174d9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/../lib/libclangFrontend.so.6+0x944d9) #39 0x00007f68d7f802d6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/bin/../lib/libclangFrontendTool.so.6+0x32d6) #40 0x0000564f525bd4d9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-6.0+0x104d9) #41 0x0000564f525b9b01 main (/usr/bin/clang-6.0+0xcb01) #42 0x00007f68d785b06b __libc_start_main (/usr/bin/../lib/libc.so.6+0x2306b) #43 0x0000564f525baf6a _start (/usr/bin/clang-6.0+0xdf6a) Stack dump: 0. Program arguments: /usr/bin/clang-6.0 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -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 -resource-dir /usr/lib/clang/6.0.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/6.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/eraz/Projects/cpp/shop -ferror-limit 19 -fmessage-length 157 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-eb7950.o -x c++ main.cpp 1. main.cpp:4:61: current parser token ')' 2. main.cpp:3:12: parsing function body 'main' 3. main.cpp:3:12: in compound statement ('{}') clang-6.0: error: unable to execute command: Segmentation fault (core dumped) clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 6.0.1 (tags/RELEASE_601/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang-6.0: note: diagnostic msg: PLEASE submit a bug report to and include the crash backtrace, preprocessed source, and associated run script. clang-6.0: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-6.0: note: diagnostic msg: /tmp/main-763743.cpp clang-6.0: note: diagnostic msg: /tmp/main-763743.sh clang-6.0: note: diagnostic msg: ********************
Created attachment 20639 [details] /tmp/main-763743.cpp Preprocessed source.
Created attachment 20640 [details] /tmp/main-763743.sh Associated run script.