------- Comment #2 from adam dot c dot scott at gmail dot com  2008-12-01 06:30 
-------
(In reply to comment #0)

> Add warning about modifying an index in a for loop.
> 
> Without this warning the kind of errors introduced in code are likely to be
> very difficult to debug (core dump).
> 
> Example code to reproduce below.  Current commandline used to compile: -ansi
> -pedantic -Wall -O.
> 
> #include <iostream>
> using namespace std;
> 
> int main(int argc, char** argv) {
>     int loopndx;
>     int indexes[10];
> 
>     for( loopndx=0 ; loopndx <=10 ; loopndx++) {
>         if (loopndx==5) {
>             loopndx=666666;
>         }
>         cout << indexes[loopndx];
>     }
>     return (EXIT_SUCCESS);
> }
> 


-- 


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

Reply via email to