Nevermind, looks like it is undefined behavior here.

On Friday, September 2, 2016 at 1:43:49 AM UTC-7, [email protected] 
wrote:
>
> Hello,
>
> I was expecting it to segfault after deallocating CString. How does it 
> work internally?
>
> func (m *Message) Test() string {
> s := C.CString("test")
> C.free(unsafe.Pointer(s))
> sh := reflect.StringHeader{(uintptr)(unsafe.Pointer(s)), 4}
> return *(*string)(unsafe.Pointer(&sh))
> }
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to