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

            Bug ID: 34134
           Summary: Segfault in clang, using auto keyword on templated
                    assignment operator.
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: m.campbellbanner...@abdn.ac.uk
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

Created attachment 18952
  --> https://bugs.llvm.org/attachment.cgi?id=18952&action=edit
Pre-processed source

The code below causes a segfault on clang++-4.0 on Ubuntu.

class A {
  template<class T>
  A(const T& a) { }

  A& operator=(const A& a) { return *this; }

  template<class T>
  auto operator=(const T& a) -> decltype(*this = A(a)) { return *this = A(a); } 
}

int main() {
}

Crash trace

#0 0x00007fecb96339a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1+0x70e9a8)
#1 0x00007fecb9631b2e llvm::sys::RunSignalHandlers()
(/usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1+0x70cb2e)
#2 0x00007fecb9631c7c (/usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1+0x70cc7c)
#3 0x00007fecbbe7d390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000000f279e3 (/usr/lib/llvm-4.0/bin/clang+0xf279e3)
#5 0x0000000000f2b800 (/usr/lib/llvm-4.0/bin/clang+0xf2b800)
#6 0x0000000000f2cdb2 (/usr/lib/llvm-4.0/bin/clang+0xf2cdb2)
#7 0x0000000000f2d126
clang::Sema::BuildCXXFunctionalCastExpr(clang::TypeSourceInfo*,
clang::SourceLocation, clang::Expr*, clang::SourceLocation)
(/usr/lib/llvm-4.0/bin/clang+0xf2d126)
#8 0x00000000010f86d4
clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) (/usr/lib/llvm-4.0/bin/clang+0x10f86d4)
#9 0x00000000012e6304 (/usr/lib/llvm-4.0/bin/clang+0x12e6304)
#10 0x00000000012e3ad8 (/usr/lib/llvm-4.0/bin/clang+0x12e3ad8)
#11 0x00000000012f3b37 (/usr/lib/llvm-4.0/bin/clang+0x12f3b37)
#12 0x00000000012e3a4c (/usr/lib/llvm-4.0/bin/clang+0x12e3a4c)
#13 0x00000000012f52a9 (/usr/lib/llvm-4.0/bin/clang+0x12f52a9)
#14 0x00000000012e38d9 (/usr/lib/llvm-4.0/bin/clang+0x12e38d9)
#15 0x00000000012f3443 (/usr/lib/llvm-4.0/bin/clang+0x12f3443)
#16 0x00000000012e3aa6 (/usr/lib/llvm-4.0/bin/clang+0x12e3aa6)
#17 0x00000000012dbd91 (/usr/lib/llvm-4.0/bin/clang+0x12dbd91)
#18 0x00000000012e1324
clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName, clang::CXXRecordDecl*, unsigned int)
(/usr/lib/llvm-4.0/bin/clang+0x12e1324)
#19 0x0000000001300998 clang::TemplateDeclInstantiator::VisitDecl(clang::Decl*)
(/usr/lib/llvm-4.0/bin/clang+0x1300998)
Stack dump:
0.      Program arguments: /usr/lib/llvm-4.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-4.0/bin/../lib/clang/4.0.0 -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
-internal-isystem /usr/include/clang/4.0.0/include/ -internal-isystem
/usr/local/include -internal-isystem
/usr/lib/llvm-4.0/bin/../lib/clang/4.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include --std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /home/mjki2mb2/CoreChemical/simcem_core/stator/build
-ferror-limit 19 -fmessage-length 133 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/test-5181f9.o -x c++ test.cpp 
1.      test.cpp:8:77: current parser token ';'
2.      test.cpp:1:1: parsing struct/union/class body 'A'
3.      test.cpp:8:56: parsing function body 'A::operator='
4.      test.cpp:8:56: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0-0ubuntu0~xedgers16.04.1 (tags/RELEASE_400/rc1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to