https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96700
Jim Wilson <wilson at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #3 from Jim Wilson <wilson at gcc dot gnu.org> --- I took another look at this. I can get this to fail with an x86_64 gcc, but that is the system compiler which is gcc-7. A little testing shows that the testcase works for x86_64 gcc-8 and later and fails for gcc-7. However, since this is a testcase for gcc-11, there is no expectation that it should work with older gcc versions. We sometimes need to modify testcases to work when gcc changes. I also tried this with rv32-elf compilers, gcc-11, gcc-10, gcc-9, and I couldn't get the testcase to fail for any of them, with or without -flto. So I can't reproduce the original poster's problem, which gets me back to my original claim that I don't think that this is a gcc bug. Actually, on second thought, I realized that I'm using the original testcase from the gcc source tree gcc.dg/tree-ssa/buitlin-sprintf.c not the attachment. Looking at the attachment, I see that some numbers have been modified. So that is why it fails. It is a bogus testcase. Looking further, I see that you are using an old version of the testcase before it was changed in 2018. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86274 which both changed an optimization and changed the testcase to match the new optimization. The fix was put on mainlnie (gcc-9) and backported to gcc-8, so the testcase should fail for any gcc-8 or later. This is invalid. You can't take a testcase from gcc-X and expect it to work with gcc-Y.