The int counter in the main loop was uninitialized, so we might end up looping a very large number of times before completing successfully. I suspect that was unintended, so I'm adding a zero initializer.
Tested on x86_64-linux-gnu, with a cross to ppc-vx7r2, where we had 'i' assigned to a register that inherited a negative value close to 0x80000000. I'm installing this as AFAICT obviously correct. Jakub, please let me know otherwise. May you and your family have a Happy Easter. for gcc/testsuite/ChangeLog * g++.dg/pr94314-3.C: Zero-initialize main loop counter. --- gcc/testsuite/g++.dg/pr94314-3.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/pr94314-3.C b/gcc/testsuite/g++.dg/pr94314-3.C index 846a5d6a3d81e..316041824c832 100644 --- a/gcc/testsuite/g++.dg/pr94314-3.C +++ b/gcc/testsuite/g++.dg/pr94314-3.C @@ -38,7 +38,7 @@ volatile int c = 1; int main () { - for (int i; i < c; i++) + for (int i = 0; i < c; i++) { idx = 0; delete new B; -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Vim, Vi, Voltei pro Emacs -- GNUlius Caesar