[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread dmitriy.ovdienko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 --- Comment #7 from Dmitriy Ovdienko --- 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

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread dmitriy.ovdienko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 --- Comment #6 from Dmitriy Ovdienko --- This code does not work ``` #include int Parse1(char const* ptr) noexcept { int result = 0; while ('\x01' != *ptr) { result = result * 10 + *ptr++ - '0'; } return result; } i

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread dmitriy.ovdienko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 Dmitriy Ovdienko changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALI

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread dmitriy.ovdienko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 --- Comment #4 from Dmitriy Ovdienko --- It happens to 2147483646, 2147483647 and std::numeric_limits::min().

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 --- Comment #3 from Jakub Jelinek --- Use -fsanitize=undefined to get it diagnosed at runtime. Although, that routine doesn't handle even Parse1("2147483631\x01") etc. correctly. Just use unsigned int result = 0;

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c++/97641] Wrong codegen if optimizer is enabled

2020-10-30 Thread dmitriy.ovdienko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97641 --- Comment #1 from Dmitriy Ovdienko --- OS: Windows 10 Distribution: MSys2 (https://www.msys2.org/) Version: (Rev4, Built by MSYS2 project) 10.2.0 I tried to reproduce this issue on https://gcc.godbolt.org/. gcc (trunk) is also unable to compil