https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103699
--- Comment #3 from Petr <kobalicek.petr at gmail dot com> --- BTW this almost seems like an optimizer bug, because if you compile the code without optimizations with GCC 11 (or with -O1) it also returns the expected value - only optimized compilation with GCC 11 returns the wrong one.