* sheepbao [180814 10:53]:
> Thank you for your detailed answer.
> I thought it would crash in this line (b.Z = "zz") of code. But it dose not
> happen and the program print "zz".
> I don't understand why this program crash in return, not in b.Z = "zz".
> Because I agree with your opinion, The
Thank you for your detailed answer.
I thought it would crash in this line (b.Z = "zz") of code. But it dose not
happen and the program print "zz".
I don't understand why this program crash in return, not in b.Z = "zz".
Because I agree with your opinion, The field Z of (*b) is beyond the
memory
* sheepbao [180813 23:45]:
> go version
> go version go1.10.2 darwin/amd64
>
> test code:
>
> func TestPoint(t *testing.T) {
> type A struct {
> X int
> Y string
> }
> type B struct {
> X int
> Y string
> Z string
> }
>
> a := A{X: 2,
I just want to research how golang func stack work.
On Tuesday, August 14, 2018 at 12:46:59 PM UTC+8, kortschak wrote:
>
> Why would you expect this to work?
>
> On Mon, 2018-08-13 at 20:44 -0700, sheepbao wrote:
> > go version
> > go version go1.10.2 darwin/amd64
> >
> > test code:
> >
>
Why would you expect this to work?
On Mon, 2018-08-13 at 20:44 -0700, sheepbao wrote:
> go version
> go version go1.10.2 darwin/amd64
>
> test code:
>
> func TestPoint(t *testing.T) {
> type A struct {
> X int
> Y string
> }
> type B struct {
> X int
>
go version
go version go1.10.2 darwin/amd64
test code:
func TestPoint(t *testing.T) {
type A struct {
X int
Y string
}
type B struct {
X int
Y string
Z string
}
a := A{X: 2, Y: "yy"}
b := (*B)(unsafe.Pointer())
b.Z = "zz"