// include headers, etc..
int main() {
multiset<int> m;
m.insert(1);
m.insert(2);
m.insert(3);
m.erase(std::prev(m.end()));
for (auto &i : m) {
cout << i << ' ';
}
cout << endl;
}
When I compile this code using g++ -o main main.cpp
, it works normally. However, when I compile this code using g++ -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector -o main main.cpp
, then AddressSanitizer:DEADLYSIGNAL
pops up in about 1 out of 10 runs.
I am using
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Copyright (C) 2021 Free Software Foundation, Inc.
The code is adapted from /a/19469047/19357263
Is this an error of the compiler?