Thoughts from Dan Miser RSS 2.0
 Monday, June 13, 2005
With apologies to Edsger Dijkstra, I bring you a much smaller treatise on the benefits of using Range Checking. As many of you are aware from previous entries on the topic, I have been dealing with issues relating to the PopupMode off and on for a while now. I went back to the drawing board on the problem I talked about where using API subclassing to intercept paint messages for all components on a screen was broken due to PopupMode. I rewrote my component to use VCL subclassing (i.e. assign a procedure to the WindowsProc property), and things are much better (after much trial and tribulation). Part of the trials and tribulations I was having were due to accessing a dynamic array beyond the bounds of the array. It was resulting in 'Invalid Pointer Operation" error messages when shutting down the application. Debugging didn't reveal much interesting, and not much to chase further either. However, I realized I didn't have Range Checking or Overflow Checking turned on in my project. Turning these options on and running again showed me immediately where the code was broken, and allowed me to fix the problem quickly. Without this check, I was overwriting some memory and this resulted in the Invalid Pointer error later on.

So, long story, short: Range Checking can help you quite a bit during development. I don't necessarily advocate leaving it on for production code, though.

Monday, June 13, 2005 12:40:00 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -

Tracked by:
http://9ow-information.info/18180573/index.html [Pingback]
http://9ok-information.info/73550371/heavy-equipment-operator-in-pipeline.html [Pingback]
http://9oe-information.info/75083479/index.html [Pingback]
http://9qg-information.info/79281592/index.html [Pingback]
http://9qc-information.info/10624034/catalogo-2006-scheda-telefonica.html [Pingback]
http://9op-information.info/98214775/index.html [Pingback]
http://9om-information.info/61363037/index.html [Pingback]
http://9rt-information.info/05567137/marriage-or-dating.html [Pingback]
http://9re-information.info/33118569/index.html [Pingback]
http://9st-information.info/65107139/electronic-stores.html [Pingback]
http://9sj-information.info/00363311/index.html [Pingback]
http://9sf-information.info/95834691/x-series.html [Pingback]
http://9rw-information.info/92338876/clr-dice-game.html [Pingback]
http://9uaea-le-informazioni.info/94540496/index.html [Pingback]
http://9uafa-le-informazioni.info/20823030/index.html [Pingback]
http://9uafk-le-informazioni.info/62032476/presidente-confindustria.html [Pingback]
http://9uaeh-le-informazioni.info/51037766/w-ipse-com.html [Pingback]
http://9uaed-le-informazioni.info/14013798/female-singer.html [Pingback]
http://9uafr-le-informazioni.info/15077278/hamlet-firewire.html [Pingback]
http://9uaen-le-informazioni.info/90637037/la-lettera-finanziaria.html [Pingback]
http://9uaet-le-informazioni.info/48592886/index.html [Pingback]
http://9uagk-le-informazioni.info/42490252/index.html [Pingback]
http://9uaht-le-informazioni.info/45049463/troia-negra.html [Pingback]
http://9uagj-le-informazioni.info/03709272/index.html [Pingback]
http://9uahf-le-informazioni.info/71647537/index.html [Pingback]
http://9uagi-le-informazioni.info/91381690/index.html [Pingback]
http://9uahb-le-informazioni.info/11684382/index.html [Pingback]
http://9uagd-le-informazioni.info/80584786/carta-duel-master.html [Pingback]
http://9uagb-le-informazioni.info/41114844/crash-test-alfa.html [Pingback]
Monday, June 13, 2005 2:14:00 PM (Central Standard Time, UTC-06:00)
FWIW, Borland doesn't support building VCL with Range Checking turned on. Btw, Nick claims that some spammers have broken the CAPTCHA that you're using (I think you guys use the same thing). Now, where is that RTV post?

-Steve
Friday, June 17, 2005 9:10:00 AM (Central Standard Time, UTC-06:00)
Perhaps I didn't understand the blog. Why wouldn't one perform range checking in the loop or before accessing the array (using the appropriate getLength or Bounds method)? This is basic and should be common practice that happens in auto mode. Just blindly accessing arrays is one of the poorest practices I've ever heard of!
DotNet Rules
Friday, June 17, 2005 11:54:00 AM (Central Standard Time, UTC-06:00)
Yes, I agree. You should check the array index before accessing the array. However, allowing that not everyone is perfect, and that mistakes happen from time to time, the code in question did not do that. Turning range checking on put the spotlight on the problem so the appropriate check could be implemented in no time.



If someone writes code that never will fail from range checking, then I guess this entry will have zero utility to them. :-)
Comments are closed.
Navigation
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)