This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31288] New: Infinite for loop while initializing char array


I have a simple for for loop that initializes a char array and never stops.
Here is a small sample program that simulated the problem.

#include <stdio.h>

int main(int argc, char *argv[]){

   int i=0;
   char     name_array[7][100];

   for (i=0; i <= 7; i++)
   {
      printf("Loop i: %d\n", i);
      name_array[i][0] = '\0';
   }

   return 1;
}


Here are my compile options

g++ -o testloop testloop.cpp

Example of the output

Loop i: 1
Loop i: 2
Loop i: 3
Loop i: 4
Loop i: 5
Loop i: 6
Loop i: 7
Loop i: 1
Loop i: 2
Loop i: 3
Loop i: 4
Loop i: 5
Loop i: 6
Loop i: 7
Loop i: 1
Loop i: 2
Loop i: 3
Loop i: 4
Loop i: 5
Loop i: 6


-- 
           Summary: Infinite for loop while initializing char array
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bryan_sauser at pa-ucl dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31288


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]