Issue |
128627
|
Summary |
libc++ hardening mode doesn't detect
|
Labels |
libc++
|
Assignees |
|
Reporter |
thesamesam
|
Noticed when reading https://jacko.io/smart_pointers.html.
libc++'s hardening mode doesn't detect the following, even with `-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG`, while `-D_GLIBCXX_DEBUG` (though not `-D_GLIBCXX_ASSERTIONS` does):
```c++
#include <vector>
int main() {
std::vector<int> my_vector = {1, 2, 3};
for (auto element : my_vector) {
if (element == 2) {
my_vector.push_back(4);
/* The next loop iteration reads a dangling pointer. */
}
}
}
```
godbolt: https://godbolt.org/z/jKaYPY3vb
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs