home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3721 < prev    next >
Encoding:
Text File  |  1992-12-16  |  2.4 KB  |  51 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!spool.mu.edu!agate!dog.ee.lbl.gov!news!nosc!dale.cts.com!jhb
  3. From: jhb@dale.cts.com (John Bollenbacher)
  4. Subject: Re: Language pitfalls (was Re: FORTRAN bug)
  5. Message-ID: <BzDEAH.But@dale.cts.com>
  6. Sender: news@dale.cts.com (USENET News Account)
  7. Organization: Titan Linkabit Corporation
  8. X-Newsreader: Tin 1.1 PL5
  9. References: <1992Dec16.163242.18923@ennews.eas.asu.edu>
  10. Date: Wed, 16 Dec 1992 20:59:01 GMT
  11. Lines: 38
  12.  
  13. Harry Koehnemann (koehnema@enuxha.eas.asu.edu) wrote:
  14. : In article <EACHUS.92Dec15202249@oddjob.mitre.org> eachus@oddjob.mitre.org (Robert I. Eachus) writes:
  15. : >In article <1992Dec15.203558.18211@inmet.camb.inmet.com> stt@spock.camb.inmet.com (Tucker Taft) writes:
  16. : >
  17. : >   Oh boy.  That is a nasty one.  This argues for a "friendly" 
  18. : >   Ada compiler giving a warning about any use of "null;" other
  19. : >   than the idiomatic ones like "when others => null;" or "begin null; end;"
  20. : >   (especially in a function that returns an access type ;-).
  21. : >
  22. : >    Actually, there is an Ada rule which normally catches this, and
  23. : >which Robert Dewar and I have argued should be removed in Ada 9X.  (A
  24. : >function must contain a return statement RM 6.5(1).)  If it belongs on
  25. : >the top ten list, then the rule should stay.
  26. : The "null;"/"return null;" was a problem with the base case in a
  27. : recursive function (null is overloaded, and even worse it's an
  28. : expression *and* a statement - isn't that something we hate about
  29. : C :).  This implies there will be additional returns somewhere in
  30. : the routine and it will not be caught by the compiler.  The real
  31. : problem is that there exists an execution path that can lead out
  32. : of the function without encountering a return.  
  33.  
  34. Seems to me the real problem is that there is a potential path out if the
  35. function which does not raise an exception but has the 'wrong' value, e.g.
  36.     if mumble = null then
  37.       null;
  38.     end if;
  39.     ...
  40.     return new mumble_ptr;
  41. Thanks for pointing out this gotcha. I'd never seen it before.
  42.  
  43. --
  44. -----------------------------------------------------------------------------
  45. - John Bollenbacher                                        jhb@dale.cts.com -
  46. - Titan Linkabit Corp.                                       (619) 552-9963 -
  47. - 3033 Science Park Rd.                                                     -
  48. - San Diego, Ca. 92121                                                      -
  49. -----------------------------------------------------------------------------
  50.