Issue 169642
Summary [libc++] `std::find` on array of shorts always returns `last` when `-fshort-wchar` used.
Labels libc++
Assignees
Reporter kacprzak
    Program returns length of `xs` array instead `0` when `-fshort-wchar` is used during compilation. Works as expected when `libc++` is not used.
```
#include <algorithm>
#include <array>

int main() {
  std::array<short, 2> xs = {-1, -1};
  auto it = std::find(xs.begin(), xs.end(), -1);
  return std::distance(xs.begin(), it);
}
```
Results on Ubuntu 24.04.03 LTS (LLVM 20):
```
$ clang++ main.cpp -stdlib=libc++ -fshort-wchar && ./a.out; echo $?
2
$ clang++ main.cpp -stdlib=libc++ && ./a.out; echo $?
0
$ clang++ main.cpp -fshort-wchar && ./a.out; echo $?
0
```
Compiler Explorer: https://godbolt.org/z/1focfKnqM
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to