copier icon indicating copy to clipboard operation
copier copied to clipboard

Copy Nested structs and pointers panic

Open Madongming opened this issue 4 years ago • 1 comments

Like this

type Elem1 struct {
       E Elem1
       E1 int
}

type Elem2 struct {
       E Elem2
       E1 int
}

type A struct {
       B Elem1
}

type C struct {
       B Elem2
}

a := new(A)
c := new(C)
copy(c, a)

will panic

Madongming avatar Aug 07 '20 13:08 Madongming

struct Elem1 includes Elem1?

yudgnahk avatar Oct 10 '20 03:10 yudgnahk