Issue |
119945
|
Summary |
[C++] [Strings] -- find_first_*(s, pos, n) & find_last_*(s, pos, n) give wrong result with String-Literal s, and n > than s-length
|
Labels |
|
Assignees |
|
Reporter |
PN-03
|
I'm using LLVM 19.1.5 MinGW and this issue only happens with String-Literals.
Here's the code to reproduce the issue:
```c++
string s = ":";
string x = "What a wonderful day to play. Arthur the Aardvark: has the best show";
cout << "String Index: " << x.find_first_of(s.c_str(), 21, 60) << "\n";
cout << "\n";
for(size_t n = 1; n <= 10; n++){
cout << "n = " << n << ", String-Literal Index: Find_First: " << x.find_first_of(":", 10, n);
cout << ", Find_Last: " << x.find_last_of(":", x.length(), n) << endl;
}
cout << "\n";
for(size_t n = 1; n <= 100; n *= 2){
cout << "n = " << n << ", String-Literal Index: Find_First_Not: " << x.find_first_not_of(":", 10, n);
cout << ", Find_Last_Not: " << x.find_last_not_of(":", x.length(), n) << endl;
}
```
pos = 49 is the correct result for the Find_First/Find_Last Set.
pos = 10 for Find_First_Not and pos = 67 for Find_Last_Not Set
This is the Output:
String Index: 49
n = 1, String-Literal Index: Find_First: 49, Find_Last: 49
n = 2, String-Literal Index: Find_First: 49, Find_Last: 49
n = 3, String-Literal Index: Find_First: 49, Find_Last: 49
n = 4, String-Literal Index: Find_First: 33, Find_Last: 65
n = 5, String-Literal Index: Find_First: 18, Find_Last: 65
n = 6, String-Literal Index: Find_First: 18, Find_Last: 65
n = 7, String-Literal Index: Find_First: 16, Find_Last: 65
n = 8, String-Literal Index: Find_First: 16, Find_Last: 65
n = 9, String-Literal Index: Find_First: 16, Find_Last: 65
n = 10, String-Literal Index: Find_First: 16, Find_Last: 67
n = 1, String-Literal Index: Find_First_Not: 10, Find_Last_Not: 67
n = 2, String-Literal Index: Find_First_Not: 10, Find_Last_Not: 67
n = 4, String-Literal Index: Find_First_Not: 10, Find_Last_Not: 67
n = 8, String-Literal Index: Find_First_Not: 10, Find_Last_Not: 67
n = 16, String-Literal Index: Find_First_Not: 14, Find_Last_Not: 64
n = 32, String-Literal Index: Find_First_Not: 30, Find_Last_Not: 64
n = 64, String-Literal Index: Find_First_Not: 18446744073709551615, Find_Last_Not: 18446744073709551615
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs