Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/18/05 19:33
Read: times


 
#85218 - bounds checks, error testing, comments
Responding to: ???'s previous message
Andy Neil said:
Jan Waclawek said:
PS. To feed the flames: this is also a very example of the C's weakness compared to Pascal - there is no check for overflow of either of the pointers.

That has nothing to do with the language - that's the programmer's fault.
The loop could easily have included bounds-checks on the pointers.

And if 'C' did bounds-check every single pointer reference, think what that'd do for the code's size!
Then we'd really get people saying, justifiably, "'C' generates bloatware - I have to do it in assembler" - but, of course, they'd do it in assembler without the bounds checking!


Of course, if Pascal automagically does the bounds-checking, then isn't the resulting code larger? BTW, I'm not arguing.

And you're right -- some sort of sanity check on parameters is always good.

Another thing that is important, but many programmers blow off, is the simple act of testing a function call's return value for correctness or for errors. For example, say I wanted a thousand-character string:
char *foo;
foo = (char *) malloc(1000);

would do the trick.

Of course, what did I leave out?

Obvious: I never tested to see if foo was returned NULL.

And hopefully, I freed foo somewhere else in the program.

-a

List of 36 messages in thread
TopicAuthorDate
simple serial programs examples            01/01/70 00:00      
   Hello, World            01/01/70 00:00      
      Well, yes but            01/01/70 00:00      
         very basic            01/01/70 00:00      
            My point            01/01/70 00:00      
               basic            01/01/70 00:00      
                  but...            01/01/70 00:00      
         Dear oh dear            01/01/70 00:00      
            Impossible!            01/01/70 00:00      
               Avoiding mistakes            01/01/70 00:00      
                  'C' - the sloppy programmers choice            01/01/70 00:00      
                     bloatware in Pascal, too!            01/01/70 00:00      
                        Go on then....            01/01/70 00:00      
                     Horrible C            01/01/70 00:00      
                        Horrible programmer            01/01/70 00:00      
                           If that's you...            01/01/70 00:00      
                     Author, not the language            01/01/70 00:00      
                        Caveat            01/01/70 00:00      
                        language wars            01/01/70 00:00      
                           Bloat or bugs            01/01/70 00:00      
                        singer, not the song            01/01/70 00:00      
                           verbosit/clarity            01/01/70 00:00      
                              Poor, deluded hackers...            01/01/70 00:00      
                              Commented! :-)            01/01/70 00:00      
                                 re commented            01/01/70 00:00      
                                    Comments good and evil            01/01/70 00:00      
                                    comments            01/01/70 00:00      
                                    A quote from some wise people            01/01/70 00:00      
                                       Good but...            01/01/70 00:00      
                                          why...            01/01/70 00:00      
                                             Very true            01/01/70 00:00      
                                                been there, done that            01/01/70 00:00      
                                    Correct comments :-)            01/01/70 00:00      
                                       fishing in Minnesota            01/01/70 00:00      
                                 Author, not the language            01/01/70 00:00      
                                    bounds checks, error testing, comments            01/01/70 00:00      

Back to Subject List