Reputation: 3275
I have an error in my code. This error don't always appears and I don't know how to debug it.
Error is :
Exception name: CONSTRAINT_ERROR
Message: myFile.adb:42 invalid data
value 84 not in 0..1
The referenced line is this one :
procedure myProcedure (ObjectA : in Ptr_Type;
ObjectB : in out T_Type) is
Begin
ObjectB.BOOL := ObjectA.BOOL; (line 42)
end procedure;
With
-- How myProcedure is called :
varA : aliased T_Type;
varB : aliased T_Type;
-- varA and varB are used many times
myProcedure(ObjectA => varA'Unrestricted_Access,
ObjectB => varB);
-- Where :
type T_Type is record
...
BOOL : Boolean;
end record;
type Ptr_Type is access all T_Type;
It seems to be that the code is trying to put 84 in a Boolean but I don't know how to debug that.
How can I do ?
EDIT : add more details
Upvotes: 0
Views: 214
Reputation: 551
The problem is your assignment statement in the procedure:
procedure myProcedure (ObjectA : in T_Type;
ObjectB : in out Ptr_Type) is
begin
ObjectA.BOOL := ObjectB.BOOL; (line 42)
end procedure;
You see, this ObjectA is "in" parameter - and hence you can't assign to it.
EDIT: Now that the question been fixed the problem is obvious.
Neither of the variables are initialized - and in such case, if possible, invalid value will be chosen as default initialization.
Upvotes: 1
Reputation: 4198
First, if you can, alter the BOOL : Boolean;
to BOOL : Boolean := raise Program_Error with "Uninitialized Value";
Try using ObjectA.BOOL := ObjectB.all.BOOL;
, too.
Upvotes: 1