Darren New wrote: > Christopher Smith wrote: >> What does it matter whether the array was dynamically allocated? > > Uhhhh, because the compiler doesn't know how big it is at runtime?
Doesn't matter. All it needs to prove to itself is that it is impossible for the test to fail. > In things like Ada, the size of the array is stored with the array, and > the compiler knows that. In C++, the size of the array is a separate > variable, and if you say > for (i = 0; i < array_size; i++) myarray[i] = ... > the compiler has no way of knowing that array_size has anything to with > the allocated size of myarray. Right, but if you overload operator[] to do bounds checking on the array, and you get array_size from the same original source that operator[] checks against, the compiler will recognize the operation is redundant and remove it. --Chris -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
