https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641
--- Comment #7 from Dmitriy Ovdienko <dmitriy.ovdienko at gmail dot com> ---
If I change the body of the loop like this, it also works
```
while ('\x01' != *ptr)
{
result = result * 10 - '0' + *ptr++;
}
```
Looks like integer overflow happens on last iteration and compiler treats it as
a UB.
