X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Cesar Rabak Newsgroups: comp.os.msdos.djgpp Subject: Re: assembly code of the "strange error" - program Date: Tue, 27 Jul 2004 17:04:38 -0300 Lines: 56 Message-ID: <4106B556.9010503@acm.org> References: <20040727070949 DOT 29244 DOT 00000306 AT mb-m19 DOT aol DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de sVr9Zhime53I3H9Th0qxpweCY93sjszwWnvieKnsXSLmyaEFg= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: pt-br, pt To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Sterten escreveu: > Paul Wilkins wrote: > > >R[r] is looping with the r index being reduced by one each time, so the > >program is accessing R[3], R[2], R[1], R[0], and then on to R[-1], > >R[-2], etc.. > > yes > > >Most people will now be feeling a sense of horror, at seeing negative > >array indexes, because arrays ARE NOT supposed to have negative indicies. > > and that should be reason enough for a good compiler to issue a runtime > warning at this point. The reason why gcc doesn't do this is mere > program-speed, I assume. But this warning/error suppressing > could also be put into one of the optimising switches "-Ox" IMO. > Guenter, As the issue of how hard is for the compiler to work this out has been discussed already in the post, let's see how a language construct can help you here: instead of (plainly): m55:r--;if(R[r]!=1)goto m55; do this: #include . . . m55: r--; assert( r > 0 ); if(R[r]!=1) goto m55; . . . Now your program will abort if the condition above "(r > 0)" is violated and will give you a nice report on where in you program this ocurred. For further details, check the library documentationš: C:\info libc alph assert HTH -- Cesar Rabak [1] You *have* the documentation and info reader installed, haven't you?