Closed
Description
What version of Go are you using (go version
)?
observed with go1.10+(haven't went any further back) and gcc 9(and binutils-2.31.1) on Fedora rawhide(30)
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
linux/amd64
What did you do?
go tool dist test -v -v -k or go test std
What did you expect to see?
tests passing
What did you see instead?
tests build failing due to werror, respectively due to Waddress-of-packed-member
run: go list -gcflags=all= -ldflags=all= -f={{if .Stale}} STALE {{.ImportPath}}: {{.StaleReason}}{{end}} std DONE
go test -short -count=1 -tags= -run= -ldflags -linkmode=external
# _/builddir/build/BUILD/go/misc/cgo/test/issue27340
cgo-gcc-prolog: In function '_cgo_942106f15754_Cfunc_issue27340CFunc':
cgo-gcc-prolog:40:24: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_942106f15754_Cfunc_issue27340Ptr':
cgo-gcc-prolog:55:55: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
# _/builddir/build/BUILD/go/misc/cgo/test
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_cTest':
cgo-gcc-prolog:40:14: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_makeEvent':
cgo-gcc-prolog:52:18: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_same':
cgo-gcc-prolog:76:22: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cc1: all warnings being treated as errors
FAIL _/builddir/build/BUILD/go/misc/cgo/test [build failed]
or you can see only the warning triggered during the build/tests
# net
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_C2func_getaddrinfo':
cgo-gcc-prolog:49:53: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog:49:65: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_Cfunc_freeaddrinfo':
cgo-gcc-prolog:66:21: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_Cfunc_getaddrinfo':
cgo-gcc-prolog:104:53: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog:104:65: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
ok context 0.992s
I'm not sure if this is a real issue/bug or just adding the suppressive gcc pragma// #pragma GCC diagnostic ignored "-Waddress-of-packed-member"
in to the generated CGo code will be the right solution.