* Re: Access to function causes "access check failed"
[not found] <32495535.655.1325020811299.JavaMail.geo-discussion-forums@vbls16>
@ 2011-12-27 22:29 ` Robert A Duff
2011-12-27 22:42 ` Niklas Holsti
1 sibling, 0 replies; 2+ messages in thread
From: Robert A Duff @ 2011-12-27 22:29 UTC (permalink / raw)
Alex <alexandre.konieczny@gmail.com> writes:
> The My_T : T1 declaration in t.adb caused the check failed error on
> line of "type T1 is record". I wonder why I have such an error, if
> it's normal or not. Any ideas ?
Access values are default-initialized to null, and you declared the
thing "not null", so it raises C_E when initialized.
Try a subtype predicate (Ada 2012 feature); they're better behaved in
this regard.
- Bob
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Access to function causes "access check failed"
[not found] <32495535.655.1325020811299.JavaMail.geo-discussion-forums@vbls16>
2011-12-27 22:29 ` Access to function causes "access check failed" Robert A Duff
@ 2011-12-27 22:42 ` Niklas Holsti
1 sibling, 0 replies; 2+ messages in thread
From: Niklas Holsti @ 2011-12-27 22:42 UTC (permalink / raw)
On 11-12-27 23:20 , Alex wrote:
> Hi everyone!
>
> I have a question about access to functions. With the example below :
>
> -- main.adb
> with T;
> procedure Main is
> begin
> T.P;
> end Main;
>
> -- t.ads
> package T is
> type T_Procedure_Params_Access is not null access
> function (Request : Integer;
> Params : Integer) return Integer;
>
> procedure P;
> private
> type T1 is record
> I : T_Procedure_Params_Access;
> end record;
> end T;
>
> -- t.adb
> package body T is
> My_T : T1;
> procedure P is
> begin
> null;
> end P;
> end T;
>
> The My_T : T1 declaration in t.adb caused the check
> failed error on line of "type T1 is record". I wonder why
> I have such an error, if it's normal or not. Any ideas ?
You have declared T_Procedure_Params_Access as "not null", but the
component T1.I is not given an initial value, so the declaration of My_T
gives My_T.I the default initial value null, which fails the "not null"
constraint.
Either remove the "not null" constraint on T_Procedure_Params_Access, or
give My_T.I a non-null initial value in some way.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-27 22:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <32495535.655.1325020811299.JavaMail.geo-discussion-forums@vbls16>
2011-12-27 22:29 ` Access to function causes "access check failed" Robert A Duff
2011-12-27 22:42 ` Niklas Holsti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox