[llvm-bugs] [Bug 41274] New: _LIBCPP_DEBUG=1 std::transform in-place: abort() (Attempted to dereference a non-dereferenceable iterator)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 28 07:17:54 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41274
Bug ID: 41274
Summary: _LIBCPP_DEBUG=1 std::transform in-place: abort()
(Attempted to dereference a non-dereferenceable
iterator)
Product: libc++
Version: 8.0
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: andi.schulz at me.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
When using std::transform on a copy-initialized std::string to transform it
in-place, compiling the program with -D_LIBCPP_DEBUG=1 makes the iterator
checks at runtime fail. When compiling without the debug flag, the program
works both optimized and unoptimized as expected. I'm using the LLVM 8.0.0
release build on macOS, installed to /usr/local/opt/llvm.
Example program:
#include <algorithm>
#include <iostream>
int main(int argc, char *argv[]) {
std::string source = "hello";
std::string the_copy = source;
std::transform(source.begin(), source.end(), source.begin(), [](unsigned
char c) -> unsigned char {
return std::toupper(c);
});
std::cout << "transformed source: " << source << "\n\n";
std::transform(the_copy.begin(), the_copy.end(), the_copy.begin(),
[](unsigned char c) -> unsigned char {
return std::toupper(c);
});
std::cout << "transformed copy: " << the_copy << "\n\n";
}
Compile command:
/usr/local/opt/llvm/bin/clang++ main.cpp -o main -D_LIBCPP_DEBUG=1 -g -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
/usr/local/opt/llvm/lib/libc++.a -lc++abi -nodefaultlibs -lSystem -std=c++17
Output:
transformed source: HELLO
/usr/local/opt/llvm/bin/../include/c++/v1/iterator:1372: _LIBCPP_ASSERT
'__get_const_db()->__dereferenceable(this)' failed. Attempted to dereference a
non-dereferenceable iterator
[1] 32560 abort ./main
--
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/20190328/66965376/attachment.html>
More information about the llvm-bugs
mailing list