Cygwin Memory Handling in Arrays

Mumit Khan khan@xraylith.wisc.EDU
Sat Jul 31 18:34:00 GMT 1999


"Ward Correll" <wardless@hotmail.com> writes:
> How does Cygwin manage memory in this c++ program?
> I thought that either the arrays sentinelOne[3] or sentinelTwo[3]would have 
> been over written containing the value from writting past the end of the 
> array TargetArray[25].  What happened here?

You thought wrong. Your code is invokes undefined behaviour in C and C++
(writing outside of array bounds), and an implementation is free to do
whatever it chooses.

The answer to your question lies in how the stack variables are aligned,
and you can get an insight by changing the index from 26 to say 28 and
see what happens.

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list