https://llvm.org/bugs/show_bug.cgi?id=28598
Bug ID: 28598 Summary: Assigning a gsl::span<const int> to a gsl::span<int> const causes segmentation fault during compilation. Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: ibb...@hotmail.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16760 --> https://llvm.org/bugs/attachment.cgi?id=16760&action=edit Archive containing main.cpp producing the crash, output from crashed compilation and log files created by clang. # Overview Using Microsoft's implementation of the Guidelines Support Library, available at https://github.com/Microsoft/GSL. Initializing a local variable of type `span<int> const` with the return value of a function returning a `span<int const>` causes the compiler crash with a segmentation fault. Notice the misplaced `const` in the declaration of the local variable. Attached is a reduced, i.e., with no dependence on GSL, version of span<T> along with a use case that causes the crash, the output I get when I compile and a pair of files that the clang error handler created. # Steps to reproduce Build the attached main.cpp file using clang++-3.8 -std=c++14 -c -o main.o main.cpp # Actual result Crash in clang. Last few frames of stack trace is #0 0x00007f6da13efcb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1+0x5a4cb8) #1 0x00007f6da13edf56 llvm::sys::RunSignalHandlers() (/usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1+0x5a2f56) #2 0x00007f6da13ee0b9 (/usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1+0x5a30b9) #3 0x00007f6da0510250 (/lib/x86_64-linux-gnu/libc.so.6+0x35250) #4 0x00000000013b3607 (/usr/lib/llvm-3.8/bin/clang+0x13b3607) #5 0x00000000013bb322 (/usr/lib/llvm-3.8/bin/clang+0x13bb322) #6 0x00000000013bd729 clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) (/usr/lib/llvm-3.8/bin/clang+0x13bd729) #7 0x00000000006bc6b7 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/llvm-3.8/bin/clang+0x6bc6b7) Full stack trace available in the attachments. # Expected results Error message pointing out the invalid conversion. # Build date and platform Ubuntu 15.10. clang from llvm's Ubuntu repositories: deb http://llvm.org/apt/wily/ llvm-toolchain-wily-3.8 main. clang version 3.8.1-svn271772-1~exp1 (branches/release_38) Target: x86_64-unknown-linux-gnu # Additional builds and platforms Using clang++-3.7 I get no crash and the following expected output: $ clang++-3.7 -std=c++14 -c -o main.o main.cpp main.cpp:15:7: error: cannot initialize a member subobject of type 'add_pointer_t<int>' with an lvalue of type 'const add_pointer_t<const int>' data_(other.data_) ^ ~~~~~~~~~~~ main.cpp:30:26: note: in instantiation of function template specialization 'span<int>::span<const int>' requested here span<int> const span = getSpan(); ^ 1 error generated. -- 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