comp.lang.ada
 help / color / mirror / Atom feed
* problem with usage of aliased
@ 2001-10-26 14:47 Stijn Rammeloo
  2001-10-26 15:05 ` Ted Dennison
  0 siblings, 1 reply; 3+ messages in thread
From: Stijn Rammeloo @ 2001-10-26 14:47 UTC (permalink / raw)


Hello,

While writing an interface package for file-manipulation routines I get
following error with gnat: ..."non-local pointer cannot point to local
object."

Gnat flags the code as errornous when I apply the 'Access attribute on the
Current_Part object (which is declared as being alliased). After some
thaught I unserstood why gnat did not liked the code (I'm declaring an
object as being aliased on the stack and pass it on to the Mkdir routine so
there is a potential chance it might get out of scope, when I try to access
it later (or something like that)). However a) I'm passing this as a
parameter to something which is clearly defined as being a function (eg. no
side effects assumed). b) I'm 100% sure I cannot get a dangling pointer. So
my question pops down to this: How can I tell an ada compiler/gnat to stop
nagging in this particular case :-)

   function Mkdir(Char : Interfaces.C.Strings.Chars_Ptr)
     return Interfaces.C.Int;
   pragma Import (Convention => C,
                    Entity => Mkdir,
                    External_Name => "mkdir");

   procedure Try_Create_Next_Missing_Part(Directory: in     Path_Name) is
      Current_Part     : aliased Interfaces.C.Char_Array :=
        Interfaces.C.To_C(To_String(Get_First_Filename_Part(Directory)));
      Remaining_Parts  : Path_Name :=
Get_Remaining_Filename_Part(Directory);

      Status           : Interfaces.C.Int;
   begin

      if not Is_Directory(Directory) then
         Status :=
Mkdir(Interfaces.C.Strings.To_Chars_Ptr(Current_Part'Access));
      end if;

      if Remaining_Parts /= Null_Path_Name then
         Try_Create_Next_Missing_Part(Remaining_Parts);
      end if;
   end Try_Create_Next_Missing_Part;

Thanks in foresee,
Stijn





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with usage of aliased
  2001-10-26 14:47 problem with usage of aliased Stijn Rammeloo
@ 2001-10-26 15:05 ` Ted Dennison
  2001-10-27  2:12   ` DuckE
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Dennison @ 2001-10-26 15:05 UTC (permalink / raw)


In article <9rbsln$6m6$1@inf6serv.rug.ac.be>, Stijn Rammeloo says...
>While writing an interface package for file-manipulation routines I get
>following error with gnat: ..."non-local pointer cannot point to local
>object."
..
>side effects assumed). b) I'm 100% sure I cannot get a dangling pointer. So
>my question pops down to this: How can I tell an ada compiler/gnat to stop
>nagging in this particular case :-)

Use 'Uchecked_Access instead of 'Access. That's what its for.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with usage of aliased
  2001-10-26 15:05 ` Ted Dennison
@ 2001-10-27  2:12   ` DuckE
  0 siblings, 0 replies; 3+ messages in thread
From: DuckE @ 2001-10-27  2:12 UTC (permalink / raw)


Or rather:
  'Unchecked_Access

(sans typo).

SteveD

"Ted Dennison" <dennison@telepath.com> wrote in message
news:DYeC7.1509$xS6.2118@www.newsranger.com...
> In article <9rbsln$6m6$1@inf6serv.rug.ac.be>, Stijn Rammeloo says...
> >While writing an interface package for file-manipulation routines I get
> >following error with gnat: ..."non-local pointer cannot point to local
> >object."
> ..
> >side effects assumed). b) I'm 100% sure I cannot get a dangling pointer.
So
> >my question pops down to this: How can I tell an ada compiler/gnat to
stop
> >nagging in this particular case :-)
>
> Use 'Uchecked_Access instead of 'Access. That's what its for.
>
> ---
> T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
>
> No trees were killed in the sending of this message.
> However a large number of electrons were terribly inconvenienced.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-10-27  2:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-26 14:47 problem with usage of aliased Stijn Rammeloo
2001-10-26 15:05 ` Ted Dennison
2001-10-27  2:12   ` DuckE

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