> > Second you are invoking undefined behavior by accessing passed the array > > bounds (or allocated > > bounds by malloc). > > I didnt get your point. I am allocating space only for 400 inregers > then as soon as in the loop if it crosses the value of 400 , it should > have given a segementation voilation ? > But is isint. Fine i agree this is not the job of the compiler, It > might never come into exesitence during the execution time, But Still > me must get a segmentation voilation by the operating system.
No, no, no. You don't understand at all undefined behavior. Anything can happen. If you pass 400*sizeof(int) then it might work or it might not. It all depends on where the malloc allocates its memory. It could malloc it at the end of the page so that you will get a seg fault right away or after a while. --- Pinski