On Fri, Mar 1, 2013 at 2:36 PM, David DENG <
david...@gmail.com> wrote:
> For illegal pointer, I actually meant dangling pointers.
>
> If so, it should be clearly pointed out in the document, I think. It seems
> not everybody thinks it in that way.
Sorry, I'm still not sure what you are getting at.
Yes, you can construct a dangling pointer using unsafe.Pointer. Don't
do that. It's unsafe.
It won't break the GC, though. The GC will simply ignore a pointer
value that does not point into the GC heap area.
Ian
> On Saturday, March 2, 2013 6:26:18 AM UTC+8, Ian Lance Taylor wrote:
>>
>> On Fri, Mar 1, 2013 at 2:18 PM, David DENG <
david...@gmail.com> wrote:
>> > Some questions about unsafe.Pointer:
>> >
>> > If an object is reference only be a unsafe.Pointer, will this object be
>> > collected?
>>
>> Yes.
>>
>> > If the fields of the object contain some pointers as well, how about
>> > those
>> > pointers, will they be collected?
>>
>> Yes.
>>
>> > If the answers are both NO, how does it do it? Does unsafe.Pointer save
>> > the
>> > type information internally?
>> > If one of the answers is YES, it means the Pointer will be an illegal
>> > pointer, right?
>>
>> I'm not sure what you mean by "illegal pointer" here. When the GC
>> sees an unsafe.Pointer, it collects the block to which it points
>> conservatively.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>