comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: A simple question about the "new" allocator
Date: Tue, 12 Aug 2014 09:07:45 -0700
Date: 2014-08-12T09:07:45-07:00	[thread overview]
Message-ID: <lsde4h$nnn$1@dont-email.me> (raw)
In-Reply-To: <d4137ad0-148a-4cf9-a6d8-c36e60ae7c9f@googlegroups.com>

On 08/11/2014 11:54 PM, NiGHTS wrote:
> With all default configurations using a typical Ada compiler, will the
> following code run indefinitely without fail or will it eventually crash?

With a typical Ada compiler, your program will crash. Ada's definition allows 
garbage collection but doesn't require it. I'm not aware of any compiler that 
implements it.

> If this does crash, what would be another way to write this program so that
> it does not crash? I would prefer not to use Ada.Unchecked_Deallocation.

If it didn't crash, your program would run forever without any visible effect; 
it's quite easy to write such a program. Presuming that's not what you're 
asking, you can repeatedly allocate memory using a safe pointer without running 
out of memory:

with PragmARC.Safe_Pointers;

procedure Does_Not_Crash is
    package Positive_Pointers is new PragmARC.Safe_Pointers (Object => Positive);

    Test : Positive_Pointers.Safe_Pointer;
begin -- Does_Not_Crash
    loop
       Test := Positive_Pointers.Allocate;
    end loop;
end Does_Not_Crash;

-- 
Jeff Carter
"There's no messiah here. There's a mess all right, but no messiah."
Monty Python's Life of Brian
84


  parent reply	other threads:[~2014-08-12 16:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  6:54 A simple question about the "new" allocator NiGHTS
2014-08-12  7:35 ` Dmitry A. Kazakov
2014-08-12 13:38   ` G.B.
2014-08-12 10:29 ` sbelmont700
2014-08-12 18:49   ` Shark8
2014-08-12 19:10     ` Adam Beneschan
2014-08-12 21:53       ` Niklas Holsti
2014-08-12 22:34         ` Adam Beneschan
2014-08-12 23:14           ` sbelmont700
2014-08-12 23:41             ` Adam Beneschan
2014-08-13  7:36               ` Dmitry A. Kazakov
2014-08-13 15:04                 ` Adam Beneschan
2014-08-13 20:32           ` Niklas Holsti
2014-08-12 15:10 ` Adam Beneschan
2014-08-12 16:07 ` Jeffrey Carter [this message]
2014-08-12 19:58   ` Robert A Duff
2014-08-12 17:51 ` NiGHTS
replies disabled

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