UPD: It is a compiler bug, and is resolved since gcc 12.3. Further information is on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459.
[Apologize for my poor English.]
The code at https://godbolt.org/z/PP1TTdhxf outputs 1. However, if you simulate the code, the answer is obviously 20.
Further exploration showed that the compiler compiled function qpw, but did not call it. Uncomment line 22 solves the issue, surprisingly. Further more, the bug seems to only occur on gcc12.1 and gcc12.2, with -O2 enabled.
I believe the code does not contain any undefined / unspecified behavior.