https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111714
Bug ID: 111714
Summary: Strange behavior when casting std::size_t to bool, UB
or compiler bug?
Product: gcc
Version: 9.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: carlosgalvezp at gmail dot com
Target Milestone: ---
Created attachment 56067
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56067&action=edit
Test case
Hi!
We are bumping from GCC 7.5 to 9.4 and one of our tests fail. The test works on
GCC 10 and above, as well as Clang trunk. Sanitizers (GCC and Clang) and
Valgrind don't report anything.
I have managed to create a minimal example here:
https://godbolt.org/z/3q7c4qYzE (attached to the bug as a file as well).
There's also comments about changes to the code that can make the test pass.
This smells a lot like UB, but I can't figure out what is wrong with the code.
Otherwise it could well be a compiler bug. Is there anything obvious you can
see that could explain the behavior?
Thanks!