From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: Bug in DJGPP? Date: Sun, 05 Oct 1997 10:18:03 -0400 Organization: Cornell University http://www.cornell.edu Lines: 60 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <3437A19B.176EF570@cornell.edu> References: <3437974D DOT E060AD2A AT mail DOT linkease DOT com DOT tw> NNTP-Posting-Host: cu-dialup-0084.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Liche wrote: > > I use DJGPP v2.01, with RHIDE 1.4. > When I compile this code: > #include > > short counter() > { > auto short count; > count ++; > cout << count << " "; > return 0; > } > > int main() > { > short i; > for (i = 0; i < 10; i ++) > counter(); > return 0; > } > > This is displayed: > 1 2 3 4 5 6 7 8 9 10 > > This happens everytime. Shouldn't the values returned be random? > If I change auto short count; with auto short count = 20; , however, > this is displayed: > 21 22 23 24 25 26 27 28 29 30 > > Is this a problem with me, DJGPP, or RHIDE? you. the first one is not very surprising. the values are not supposed to be random; they are just undefined; i.e. the memory location is not initialized when the variable is created. i don't understand the second case, are you saying that djgpp fails to initialize count with 20 in the following function: > short counter() > { > auto short count = 20; > count ++; > cout << count << " "; > return 0; > } if you made this change, and you did not get 21 21 21 21 21 21 ... i can't be 100% certain (i don't feel like booting back to dos right now) but i seriously doubt you second claim. -- ---------------------------------------------------------------------- A. Sinan Unur Department of Policy Analysis and Management, College of Human Ecology, Cornell University, Ithaca, NY 14853, USA mailto:sinan DOT unur AT cornell DOT edu http://www.people.cornell.edu/pages/asu1/