[llvm-bugs] [Bug 37681] New: Invalid template member specialization causes ICE

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 4 12:13:10 PDT 2018


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

            Bug ID: 37681
           Summary: Invalid template member specialization causes ICE
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ldalessandro at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20393
  --> https://bugs.llvm.org/attachment.cgi?id=20393&action=edit
preprocessed source

~/temp$ cat test.cpp 
#include <cstddef>

template <std::size_t N>
struct Foo {
  template <class U> Foo operator*(U&& rhs) const { return *this; }
  template <> Foo operator*<const Foo&>(const Foo& rhs) const { return *this; }
};

int main() {
  Foo<1> a;
}

~/temp$ clang++ --version
clang version 6.0.0-3+b1 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

~/temp$ clang++ test.cpp 
test.cpp:6:19: error: cannot specialize a function 'operator*' within class
scope
  template <> Foo operator*<const Foo&>(const Foo& rhs) const { return *this; }
                  ^
test.cpp:6:19: error: no function template matches function template
specialization 'operator*'
test.cpp:10:10: note: in instantiation of template class 'Foo<1>' requested
here
  Foo<1> a;
         ^
#0 0x00007fe3627f7b6a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x8edb6a)
#1 0x00007fe3627f5ea6 llvm::sys::RunSignalHandlers()
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x8ebea6)
#2 0x00007fe3627f5fc3 (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x8ebfc3)
#3 0x00007fe365a32f50 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11f50)
#4 0x000055d67015ef0d (/usr/lib/llvm-6.0/bin/clang+0x1224f0d)
#5 0x000055d67015f1cf
clang::TemplateSpecCandidateSet::NoteCandidates(clang::Sema&,
clang::SourceLocation) (/usr/lib/llvm-6.0/bin/clang+0x12251cf)
#6 0x000055d67022e2ba
clang::Sema::getMostSpecialized(clang::UnresolvedSetIterator,
clang::UnresolvedSetIterator, clang::TemplateSpecCandidateSet&,
clang::SourceLocation, clang::PartialDiagnostic const&,
clang::PartialDiagnostic const&, clang::PartialDiagnostic const&, bool,
clang::QualType) (/usr/lib/llvm-6.0/bin/clang+0x12f42ba)
#7 0x000055d6702015fd
clang::Sema::CheckFunctionTemplateSpecialization(clang::FunctionDecl*,
clang::TemplateArgumentListInfo*, clang::LookupResult&)
(/usr/lib/llvm-6.0/bin/clang+0x12c75fd)
#8 0x000055d670294391
clang::TemplateDeclInstantiator::VisitClassScopeFunctionSpecializationDecl(clang::ClassScopeFunctionSpecializationDecl*)
(/usr/lib/llvm-6.0/bin/clang+0x135a391)
#9 0x000055d670274917 clang::Sema::InstantiateClass(clang::SourceLocation,
clang::CXXRecordDecl*, clang::CXXRecordDecl*,
clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool)
(/usr/lib/llvm-6.0/bin/clang+0x133a917)
#10 0x000055d67027f5b3
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) (/usr/lib/llvm-6.0/bin/clang+0x13455b3)
#11 0x000055d6702bd0ed
clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser*) (/usr/lib/llvm-6.0/bin/clang+0x13830ed)
#12 0x000055d6702bd445 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, clang::Sema::TypeDiagnoser&)
(/usr/lib/llvm-6.0/bin/clang+0x1383445)
#13 0x000055d6702bd57f clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, unsigned int) (/usr/lib/llvm-6.0/bin/clang+0x138357f)
#14 0x000055d66fe9ce3f clang::Sema::ActOnUninitializedDecl(clang::Decl*)
(/usr/lib/llvm-6.0/bin/clang+0xf62e3f)
#15 0x000055d66fc06437
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-6.0/bin/clang+0xccc437)
#16 0x000055d66fc17056 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-6.0/bin/clang+0xcdd056)
#17 0x000055d66fc19c83
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*) (/usr/lib/llvm-6.0/bin/clang+0xcdfc83)
#18 0x000055d66fc19f8b
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-6.0/bin/clang+0xcdff8b)
#19 0x000055d66fc7cc45
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-6.0/bin/clang+0xd42c45)
#20 0x000055d66fc7d2e8
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*)
(/usr/lib/llvm-6.0/bin/clang+0xd432e8)
#21 0x000055d66fc80c1c clang::Parser::ParseCompoundStatementBody(bool)
(/usr/lib/llvm-6.0/bin/clang+0xd46c1c)
#22 0x000055d66fc83209 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/lib/llvm-6.0/bin/clang+0xd49209)
#23 0x000055d66fbf5fb8
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/lib/llvm-6.0/bin/clang+0xcbbfb8)
#24 0x000055d66fc16f18 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-6.0/bin/clang+0xcdcf18)
#25 0x000055d66fbf1ab1
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/lib/llvm-6.0/bin/clang+0xcb7ab1)
#26 0x000055d66fbf20f1 (/usr/lib/llvm-6.0/bin/clang+0xcb80f1)
#27 0x000055d66fbf7f75
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib/llvm-6.0/bin/clang+0xcbdf75)
#28 0x000055d66fbf8f39
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-6.0/bin/clang+0xcbef39)
#29 0x000055d66fbee3c2 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-6.0/bin/clang+0xcb43c2)
#30 0x000055d66f9669f1 clang::CodeGenAction::ExecuteAction()
(/usr/lib/llvm-6.0/bin/clang+0xa2c9f1)
#31 0x000055d66f7a90f6 clang::FrontendAction::Execute()
(/usr/lib/llvm-6.0/bin/clang+0x86f0f6)
#32 0x000055d66f7735cc
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-6.0/bin/clang+0x8395cc)
#33 0x000055d66f851183
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-6.0/bin/clang+0x917183)
#34 0x000055d66f391008 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-6.0/bin/clang+0x457008)
#35 0x000055d66f37fd69 main (/usr/lib/llvm-6.0/bin/clang+0x445d69)
#36 0x00007fe361011a87 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21a87)
#37 0x000055d66f38ebba _start (/usr/lib/llvm-6.0/bin/clang+0x454bba)
Stack dump:
0.      Program arguments: /usr/lib/llvm-6.0/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name test.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 -resource-dir
/usr/lib/llvm-6.0/lib/clang/6.0.0
-I/opt/intel/compilers_and_libraries_2018.1.163/linux/mkl/include
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
-internal-isystem /usr/include/clang/6.0.0/include/ -internal-isystem
/usr/local/include -internal-isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/ldalessa/temp -ferror-limit 19
-fmessage-length 211 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-ae236c.o -x c++
test.cpp 
1.      test.cpp:10:11: current parser token ';'
2.      test.cpp:9:12: parsing function body 'main'
3.      test.cpp:9:12: in compound statement ('{}')
4.      test.cpp:4:8: instantiating class definition 'Foo<1>'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0-3+b1 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: 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: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-214083.cpp
clang: note: diagnostic msg: /tmp/test-214083.sh
clang: 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/20180604/415e68f6/attachment.html>


More information about the llvm-bugs mailing list