delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/07/25/19:02:33

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-Id: <199907252124.QAA19727@mercury.xraylith.wisc.edu>
To: "Ward Correll" <wardless AT hotmail DOT com>
cc: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: Cygwin Memory Handling in Arrays
In-Reply-To: Your message of "Sun, 25 Jul 1999 17:43:15 EDT."
<19990725214317 DOT 29753 DOT qmail AT hotmail DOT com>
Date: Sun, 25 Jul 1999 16:24:42 -0500
From: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>

"Ward Correll" <wardless AT hotmail DOT 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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019