Issue 141550
Summary std::sort triggers negate-overflow ubsan
Labels new issue
Assignees
Reporter kongy
    Change 0fb76bae6b2abfe5e0a34557f365a586be989364 introduced a regression in `std::sort`.

Building
```cpp
#include <algorithm>
#include <vector>

int main() {
        std::vector<int> other_ops;
        for (int i = 0; i < 1024; ++i) {
 other_ops.push_back(i);
        }

        std::sort(other_ops.begin(), other_ops.end(), std::greater<int>());
}
```

with
```
~/llvm/build/bin/clang++ -O2 -fsanitize=integer ubsan_test.cpp -stdlib=libc++ -static-libstdc++ -l:libc++abi.a
```

crashes with the following error:
```
include/c++/v1/__bit/blsr.h:25:23: runtime error: negation of 18446744073709551615 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior include/c++/v1/__bit/blsr.h:25:23
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to