Mail Archives: djgpp/1997/10/28/08:45:23
Erik Max Francis wrote:
> Vik Heyndrickx wrote:
> > > for (auto int i = 0 ; i < 640 ; i++)
> > > for (auto int j = 0 ; j < 480 ; j++)
> > > scrn[i][j] = 0;
> > Conceptually, you are right. But that is not what the compiler
> > effectively does. The variable j gets assigned an address and every
> > instance j gets this same address. The code you get is the same when
> > you would declare i and j outside the loop.
> Then you are using an old version of gcc, or are reading off an old C++
> draft standard.
I was rather referening to the effectiveness of the compiler's
You are completely right about the scope. But the code that generates
from a routine that declares its count variables outside of the loop,
*will* be the same, because the compiler's optimizer sees that actually
not every time a new variable should be generated. Conceptually when you
are looping the outermost loopt you get every time a new j, but the
address of j will be, as a consequence, every time the same.
| Vik Heyndrickx |
- Raw text -