comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Question about base types
Date: 1997/02/10
Date: 1997-02-10T00:00:00+00:00	[thread overview]
Message-ID: <dewar.855570988@merv> (raw)
In-Reply-To: 32FB45D4.2160@watson.ibm.com


Norman suggested:

<<So impressive, in fact, that I'm going to raise the bar:  Do you issue
the same warning for unintentionally recursive controlled-type
operations?  (For a controlled type CT, these would include a version of
Initialize that creates an uninitialized object of type CT, a version of
Adjust that assigns an object of type CT, or a version of Finalize in
which an object of type CT goes out of existence, either because it was
declared in finalize, because it was uncheckedly deallocated in
Finalize, or because it was created by an allocator for an access type
declared in Finalize.)

Such cases are especially hard to diagnose because the unintentional
recursive call is implicit, i.e., you won't find it in the program text.>>


Robert replies

At least some cases of this kind are caught:

     1.    with Ada.Finalization; use Ada.Finalization;
     2.    package a is
     3.       type m is new controlled with null record;
     4.       procedure Initialize (Object : in out m);
     5.    end a;

     1.    package body a is
     2.       procedure Initialize (Object : in out m) is
     3.          x : m;
                 |
        >>> warning: infinite recursion
        >>> warning: Storage_Error will be raised at runtime

     4.       begin
     5.          null;
     6.       end;
     7.    end a;

The diagnostic here is a little mysterious, but I would hesitate to
special case it unless someone really has run into this in practice.
Generally we like to apply the reality check of someone actually
(a) running into an error that could be caught and (b) being
mystified enough to waste time looking for the error. I always
hesitate to add new diagnostics that come only from thought
experiments.

Note that we are happy to get suggestions for error checks and improved
diagnostics. The best form for such suggestions is to send a complete
source program to report@gnat.com with a suggestion of exactly what
error message you would like to see. Now sometimes, such suggestions
amount to asking the compiler to read your mind, and it is impossible
to implement them, but it is remarkable how often we *have* been able
to sort things out, even in cases which at first look very hard.

Robert Dewar
Ada Core Technologies





  parent reply	other threads:[~1997-02-10  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-26  0:00 Question about base types Matthew Heaney
1997-01-27  0:00 ` Robert A Duff
1997-01-30  0:00   ` Matthew Heaney
1997-01-30  0:00     ` Robert Dewar
1997-01-30  0:00       ` Matthew Heaney
1997-01-30  0:00     ` Matthew Heaney
     [not found]     ` <EACHUS.97Feb3221558@spectre.mitre.org>
     [not found]       ` <dewar.855063927@merv>
     [not found]         ` <EACHUS.97Feb6145918@spectre.mitre.org>
     [not found]           ` <dewar.855276722@merv>
1997-02-07  0:00             ` Mats Weber
1997-02-08  0:00               ` Robert Dewar
1997-02-10  0:00                 ` Mats Weber
1997-02-11  0:00                   ` Robert Dewar
     [not found]         ` <32FB45D4.2160@watson.ibm.com>
1997-02-10  0:00           ` Robert Dewar [this message]
1997-02-08  0:00   ` Robert Dewar
1997-02-09  0:00     ` Matthew Heaney
1997-02-09  0:00       ` Robert Dewar
1997-02-09  0:00         ` Matthew Heaney
1997-02-10  0:00           ` Robert Dewar
1997-02-10  0:00       ` Larry Kilgallen
1997-02-11  0:00   ` Robert I. Eachus
1997-02-12  0:00     ` Robert Dewar
1997-01-27  0:00 ` Mats Weber
1997-01-28  0:00   ` Robert A Duff
1997-01-29  0:00   ` Robert Dewar
1997-01-28  0:00 ` Robert I. Eachus
1997-01-28  0:00   ` Mats Weber
1997-01-29  0:00 ` Robert I. Eachus
1997-01-30  0:00   ` Robert A Duff
replies disabled

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