comp.lang.ada
 help / color / mirror / Atom feed
* More on the ACCESS STRING bug
@ 1988-02-08 11:11 paul
  0 siblings, 0 replies; only message in thread
From: paul @ 1988-02-08 11:11 UTC (permalink / raw)



                  <<< DISK$SYSTEM:[NOTES$LIBRARY]ADA.NOTE;1 >>>
                                    -< Ada >-
================================================================================
Note 12.6                 A bug in Vax Ada compiler...                    6 of 6
20514::LOUBOUTIN "Sylvain R.Y. (021/47 27 37)"       68 lines  19-JAN-1988 10:00
                             -< I don't think so >-
--------------------------------------------------------------------------------

Spencer Peterson says:
    
> The "exemple" procedure/program is ERRONEOUS.  I quote, with meaningful 
> substitutions, from the Ada Reference Manual( Chapter 13.10.1, Para. 6).
>
> "If A and B designate the same object, then accessing that object through 
> B is erroneous if this access is performed (or attempted) after the call 
> DISPOSE(A); the effect of each such access is not defined by the language."
>
> The program behaves as correctly as it can, given that it is 'legal' for
> a compiler to optimize use of storage by NOT allocating a fresh copy of 
> the string contents, although it would be prefered that a second copy be
> made and thus, no problem would occur when the original is DISPOSEd. The
> effect of making a copy of the contents of an access type, in this case,
> is the same as if B were a constant of type ACCESS_STRING, i.e.
>    B : constant ACCESS_STRING := A;
 
        I don't  agree  with  Spencer Peterson because in my example, B
    is not an  access to a string, but actually a string. So it doesn't
    designate the same object than A.
    
        My procedure would have been erroneous if I had written it like
    that:                        
    
      ...
      type ACCESS_STRING is access STRING;
      procedure DISPOSE is new UNCHECKED_DEALLOCATION (STRING, ACCESS_STRING);
      A: ACCESS_STRING := new STRING'("Ceci est un exemple...");
      B: constant ACCESS_STRING := A;
         ----------------------
      ...                           
    
      but the problem is different when the procedure is written like this: 
  
      ...
      type ACCESS_STRING is access STRING;
      procedure DISPOSE is new UNCHECKED_DEALLOCATION (STRING, ACCESS_STRING);
      A: ACCESS_STRING := new STRING'("Ceci est un exemple...");
      B: constant STRING := A.all;
         ---------------
      ...                      
    
    So I still pretend that there is a bug in the Vax Ada compiler.

      Another point, the program behaviour is correct if I use a variable
    instead of a constant:
    
      ...
      type ACCESS_STRING is access STRING;
      procedure DISPOSE is new UNCHECKED_DEALLOCATION (STRING, ACCESS_STRING);
      A: ACCESS_STRING := new STRING'("Ceci est un exemple...");
      B: STRING(A.all'RANGE) := A.all;
         ---------------
      ...                      
                      
  Sylvain Louboutin
  D.I.
  Swiss Federal
  Institute of Technology

               1015 Lausanne,
               --------------
               SWITZERLAND

  Phone: (+41 21) 47 27 37
  Email: LOUBOUTIN@CLSEPF51 (from BITNET/EARN)
         LOUBOUTIN%CLSEPF51.BITNET@WISCVM.WISC.EDU (from ARPA Internet)
     

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1988-02-08 11:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1988-02-08 11:11 More on the ACCESS STRING bug paul

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