initialize pr94314-3.C counter

Message ID
State New
Headers show
  • initialize pr94314-3.C counter
Related show

Commit Message

Alexandre Oliva April 3, 2021, 10:41 p.m.
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

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(-)

Alexandre Oliva, happy hacker
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


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;
 main ()
-  for (int i; i < c; i++)
+  for (int i = 0; i < c; i++)
       idx = 0;
       delete new B;