Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Why Does This Not Crash? (http://www.go4expert.com/forums/crash-t3797/)

it career 8Apr2007 19:47

Why Does This Not Crash?
Hello C/C++ experts,

I write the following code

int a[10];
int b[10];

//initiliaze all element of array a and b to 0.

Neither the program crashes nor the value of b[0] becomes 255
What could be the reason?

DaWei 8Apr2007 21:40

Re: Why Does This Not Crash?
The language doesn't define how those two are related, merely that each is contiguous and that element n+1 is one element higher in memory than element n. If you have a common implementation, inside a function, and that function uses the stack, which it would be stupid to count on, b[11] will write into a[0].

I would suggest that if you want to play with such stuff, get into machine language. You'll find lots of undefined behavior in C/C++ accidentally, no need to go looking for a way to turn a cotton purse into sow's excrement; nor will I, personally, teach you how to write exploits.

All times are GMT +5.5. The time now is 20:56.