comp.lang.ada
 help / color / mirror / Atom feed
From: dale.cts.com!jhb@nosc.mil  (John Bollenbacher)
Subject: Re: Language pitfalls (was Re: FORTRAN bug)
Date: 16 Dec 92 20:59:01 GMT	[thread overview]
Message-ID: <BzDEAH.But@dale.cts.com> (raw)

Harry Koehnemann (koehnema@enuxha.eas.asu.edu) wrote:
: In article <EACHUS.92Dec15202249@oddjob.mitre.org> eachus@oddjob.mitre.org (R
obert I. Eachus) writes:
: >In article <1992Dec15.203558.18211@inmet.camb.inmet.com> stt@spock.camb.inme
t.com (Tucker Taft) writes:
: >
: >   Oh boy.  That is a nasty one.  This argues for a "friendly" 
: >   Ada compiler giving a warning about any use of "null;" other
: >   than the idiomatic ones like "when others => null;" or "begin null; end;"
: >   (especially in a function that returns an access type ;-).
: >
: >    Actually, there is an Ada rule which normally catches this, and
: >which Robert Dewar and I have argued should be removed in Ada 9X.  (A
: >function must contain a return statement RM 6.5(1).)  If it belongs on
: >the top ten list, then the rule should stay.
: 
: The "null;"/"return null;" was a problem with the base case in a
: recursive function (null is overloaded, and even worse it's an
: expression *and* a statement - isn't that something we hate about
: C :).  This implies there will be additional returns somewhere in
: the routine and it will not be caught by the compiler.  The real
: problem is that there exists an execution path that can lead out
: of the function without encountering a return.  

Seems to me the real problem is that there is a potential path out if the
function which does not raise an exception but has the 'wrong' value, e.g.
    if mumble = null then
      null;
    end if;
    ...
    return new mumble_ptr;
Thanks for pointing out this gotcha. I'd never seen it before.

--
-----------------------------------------------------------------------------
- John Bollenbacher                                        jhb@dale.cts.com -
- Titan Linkabit Corp.                                       (619) 552-9963 -
- 3033 Science Park Rd.                                                     -
- San Diego, Ca. 92121                                                      -
-----------------------------------------------------------------------------

             reply	other threads:[~1992-12-16 20:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-16 20:59 John Bollenbacher [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-12-17 18:48 Language pitfalls (was Re: FORTRAN bug) John Halper
1992-12-17 14:18 Terry J. Westley
1992-12-17  1:31 Robert I. Eachus
1992-12-16 20:02 Julian C . Lander
1992-12-16 17:38 Bob Kitzberger
1992-12-16 17:27 Mark A Biggar
1992-12-16 16:32 olivea!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!asuvax!ennews
1992-12-16 14:38 crispen
1992-12-16  1:22 Robert I. Eachus
1992-12-15 20:35 news.centerline.com!noc.near.net!inmet!spock!stt
1992-12-15 18:08 Richard Pattis
1992-12-15 15:47 Michael Feldman
1992-12-15 14:55 David Emery
1992-12-15 13:55 enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!news.lth.se!dag
1992-12-14 21:57 Bob Kitzberger
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox