On Sun, Mar 23, 2003 at 09:28:21PM +0100, Alfredo Braunstein wrote: > Lars Gullik Bjønnes wrote: > > > char a[] = "Lars"; > > a[-1] yields what? AFAIK the implementation is allowed to crash. > > > > Dead sure it can crash if you _access_ a[-1], but this doesn't takes out the > fact that you can compare &a[-1] with some iterator (and it will not > crash).
a[-1] is *(a - 1), so this dereferences a pointer not pointing into the array. This is undefinied behaviour. > It's the same thing as: > > vector<int> a(10); > > if(&a[11] == &*a.end()) > cout << "yes" << endl; Indeed. Undefined behaviour as well. > This does _not_ crash and prints yes (and in fact is perfectly valid and can > even be useful). This I doubt. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)