comp.lang.ada
 help / color / mirror / Atom feed
* Newbie question about pointers in GNAT 3.15p on Windows 2000
@ 2003-02-21 21:20 David Gressett
  2003-02-21 23:03 ` David C. Hoos, Sr.
  2003-02-22 15:31 ` Steve
  0 siblings, 2 replies; 8+ messages in thread
From: David Gressett @ 2003-02-21 21:20 UTC (permalink / raw)



I have the following package which I am trying to compile with GNAT
3.15p on Windows 2000:

-----------------------------------------------------------------------
package Miscellaneous3 is

  
  function X
    return String;
    
end Miscellaneous3;


package body Miscellaneous3 is

  -----------------------
  -- X --
  -----------------------
  
  type P_Integer is access all Integer;

  function X
    return String
  is
    Bufsize: Aliased Integer;
    P_Size: P_Integer;
    
  begin
    Bufsize := 1;
    P_Size := BufSize'Access;
    return "";
  end X;

end Miscellaneous3;

---------------------------------------------------------------------
Compilation produces this error message:

miscellaneous3.adb:17:15 non-local pointer cannot point to local
object

I have no idea what "local" means here -  both the pointer P_Size and
the pointed-to variable Bufsize are defined in the same place.

What am I doing wrong?






^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Newbie question about pointers in GNAT 3.15p on Windows 2000 : to Steve
@ 2003-02-24 11:48 David C. Hoos, Sr.
  0 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos, Sr. @ 2003-02-24 11:48 UTC (permalink / raw)
  To: comp.lang.ada mail to news gateway


----- Original Message ----- 
From: "prashna" <vashwath@rediffmail.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: February 24, 2003 12:40 AM
Subject: Re: Newbie question about pointers in GNAT 3.15p on Windows 2000 : to Steve


> > If you are absolutely certain the variable will not be referenced after the
>                                     ^^^^^
> > lifetime of the procedure or function in which it is declared> 
> 
> Hi Steve, 
> This sentence is bit confisung for me.I am not sure you are talking
> about which variable. Are talking about BUFSIZE (or P_SIZE). Both
> these variables are local to function X and it is absolutely
> impossible to refer these variables outside X.Please clarify this.
> And also please let me know how it is risky if I use
> 'Unchecked_Access.
He is referring to the variable of which you are taking the 'access --
i.e., BUFSIZE.  It is risky to use 'Unchecked_Access if the result of
the 'Unchecked_Access attribute is passed outside the function, because
when BUFSIZE goes out of scope (i.e., when X returns), the result of the
'Unchecked_Access which has been passed outside of X will no longer be
valid.
> 
> Thanks in Advance
> Ashwath
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 
> 




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

end of thread, other threads:[~2003-02-25  2:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-21 21:20 Newbie question about pointers in GNAT 3.15p on Windows 2000 David Gressett
2003-02-21 23:03 ` David C. Hoos, Sr.
2003-02-24 19:05   ` David Gressett
2003-02-24 19:25     ` David Gressett
2003-02-22 15:31 ` Steve
2003-02-24  6:40   ` Newbie question about pointers in GNAT 3.15p on Windows 2000 : to Steve prashna
2003-02-25  2:57     ` Steve
  -- strict thread matches above, loose matches on Subject: below --
2003-02-24 11:48 David C. Hoos, Sr.

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