Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-16 Thread 刘桂祥
thanks a lot 在 2017年4月16日星期日 UTC+8上午12:22:13,peterGo写道: > > > For this version of your program with > > type S struct{ B byte } > > There is an allocation, > > // example.go > package main > > import ( > "runtime" > "unsafe" > ) > > type S struct{ B byte } > > func main() { > var

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread peterGo
For this version of your program with type S struct{ B byte } There is an allocation, // example.go package main import ( "runtime" "unsafe" ) type S struct{ B byte } func main() { var stats runtime.MemStats runtime.ReadMemStats() println(stats.Mallocs) var x S

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread peterGo
刘桂祥, Size and alignment guarantees https://golang.org/ref/spec#Size_and_alignment_guarantees A struct or array type has size zero if it contains no fields (or elements, respectively) that have a size greater than zero. Two distinct zero-size variables may have the same address in memory. You

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread 刘桂祥
go build -gcflags '-N -l' example.go && ./example If I use this to compile example.go it shound disable function inline and the compile code should call ref() in example.go and will call mallocgc runtimestats.Mallocs can see it but it is not. 在 2017年4月14日星期五 UTC+8下午10:01:25,Ian Lance

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-14 Thread Ian Lance Taylor
On Thu, Apr 13, 2017 at 10:45 PM, 刘桂祥 wrote: > go1.7.1 > > go run -gcflags '-N -l -m' example.go It is the -m flag that is generating the output you see. If there is some other bug, please let us know what it is. Ian > 在 2017年4月14日星期五 UTC+8下午1:18:26,Ian Lance

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-13 Thread 刘桂祥
go1.7.1 go run -gcflags '-N -l -m' example.go 在 2017年4月14日星期五 UTC+8下午1:18:26,Ian Lance Taylor写道: > > On Thu, Apr 13, 2017 at 8:33 PM, 刘桂祥 > wrote: > > // example.go > > package main > > > > > > import "runtime" > > > > > > type S struct{} > > > > > > func

[go-nuts] go build -gcflags '-N -l' don't work

2017-04-13 Thread 刘桂祥
// example.go package main import "runtime" type S struct{} func main() { var stats runtime.MemStats runtime.ReadMemStats() println(stats.Mallocs) var x S runtime.ReadMemStats() println(stats.Mallocs) _ = *ref(x) runtime.ReadMemStats() println(stats.Mallocs) } func ref(z S) *S {