Have I come up with a compiler bug?

Revision en1, by Xiaohuba, 2024-08-22 05:46:34

[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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Xiaohuba 2024-08-22 05:46:34 495 Initial revision (published)