This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cygwin Memory Handling in Arrays


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]