https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127551
Bug ID: 127551
Summary: [constexpr][c++26] same code yields different results
with and without constexpr
Product: gcc
Version: 15.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alex.irger at gmail dot com
Target Milestone: ---
Minimal example to repoduce:
Compiled as:
g++ test.cpp -std=c++26 -o test
```
#include <iostream>
#include <string_view>
int main()
{
constexpr std::string_view test = "hello";
size_t pos = test.find_first_of('l', 2);
std::cout << pos << std::endl;
return 0;
}
```
prints 4 (which is incorrect).
Same code without constexpr
```
#include <iostream>
#include <string_view>
int main()
{
std::string_view test = "hello";
size_t pos = test.find_first_of('l', 2);
std::cout << pos << std::endl;
return 0;
}
```
prints 2 (which is correct).
Both version works correctly under c++23.