comp.lang.ada
 help / color / mirror / Atom feed
From: Vincent Marciante <marciant@li.net>
Subject: Simpler Question (was Assigning to dereferenced null access variable)
Date: 2000/11/07
Date: 2000-11-07T00:00:00+00:00	[thread overview]
Message-ID: <3A0847ED.49AF@li.net> (raw)
In-Reply-To: 3A05A609.4CE6@li.net

--Okay, I cut down the question to:
--
--Why don't both blocks in the following code behave similarly?
--I get the following output using OS/2 GNAT 3.12p
--
--The Null_Characters(1..0) assignment succeeded
--The Null_Characters assignment caused Constraint_Error
--
--If the above indicates a compiler defect then what is the
--correct behavior?

with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Null_Assignments is

    type Characters is array (Positive range <>) of Character;
    Null_Characters : Characters(1..0);

    type Reference is access Characters;
    type Character_Sequence is
        record
            The_Characters : Reference;
        end record;

    Null_Sequence : Character_Sequence;
begin
    begin
        Null_Sequence.The_Characters(1..0) := Null_Characters(1..0);  
        Put_Line("The Null_Characters(1..0) assignment succeeded");
        --OS/2 GNAT 3.12 succeeds
    exception
        when Constraint_Error => 
        Put_Line("The Null_Characters(1..0) assignment caused
Constraint_Error");
    end;

    begin
        Null_Sequence.The_Characters(1..0) := Null_Characters;  
        Put_Line("The Null_Characters assignment succeeded");
    exception
        when Constraint_Error => 
        Put_Line("The Null_Characters assignment caused
Constraint_Error");
        --OS/2 GNAT 3.12 raises Constraint_Error
    end;
end;




  reply	other threads:[~2000-11-07  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-05  0:00 Assigning to dereferenced null access variable Vincent Marciante
2000-11-07  0:00 ` Vincent Marciante [this message]
2000-11-07  0:00   ` Simpler Question (was Assigning to dereferenced null access variable) Jean-Pierre Rosen
2000-11-07  0:00     ` Vincent Marciante
2000-11-08  4:20       ` Robert Dewar
2000-11-08  0:00         ` Vincent Marciante
2000-11-09  4:43           ` Robert Dewar
2000-11-08  0:00         ` GNAT for OS/2 (was Re: Simpler Question (was Assigning ...)) Vincent Marciante
2000-11-10  1:52           ` tjerick
replies disabled

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