Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence "go build" warnings #12

Merged
merged 1 commit into from
Jan 6, 2021

Conversation

nenad
Copy link
Contributor

@nenad nenad commented Aug 3, 2019

Running go build results in the following message:

$ go build
# github.com/anacrolix/go-libutp
In file included from utp_api.cpp:26:
utp_internal.h: In constructor ‘UTPSocketKey::UTPSocketKey(const PackedSockAddr&, uint32)’:
utp_internal.h:79:32: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct UTPSocketKey’; use assignment instead [-Wclass-memaccess]
   79 |   memset(this, 0, sizeof(*this));
      |                                ^
utp_internal.h:74:8: note: ‘struct UTPSocketKey’ declared here
   74 | struct UTPSocketKey {
      |        ^~~~~~~~~~~~
# github.com/anacrolix/go-libutp
In file included from utp_callbacks.h:27,
                 from utp_callbacks.cpp:25:
utp_internal.h: In constructor ‘UTPSocketKey::UTPSocketKey(const PackedSockAddr&, uint32)’:
utp_internal.h:79:32: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct UTPSocketKey’; use assignment instead [-Wclass-memaccess]
   79 |   memset(this, 0, sizeof(*this));
      |                                ^
utp_internal.h:74:8: note: ‘struct UTPSocketKey’ declared here
   74 | struct UTPSocketKey {
      |        ^~~~~~~~~~~~
# github.com/anacrolix/go-libutp
In file included from utp_internal.cpp:34:
utp_internal.h: In constructor ‘UTPSocketKey::UTPSocketKey(const PackedSockAddr&, uint32)’:
utp_internal.h:79:32: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct UTPSocketKey’; use assignment instead [-Wclass-memaccess]
   79 |   memset(this, 0, sizeof(*this));
      |                                ^
utp_internal.h:74:8: note: ‘struct UTPSocketKey’ declared here
   74 | struct UTPSocketKey {
      |        ^~~~~~~~~~~~

Go version:

$ go version
go version go1.12.7 linux/amd64

I found the solution from intel's TBB repository: oneapi-src/oneTBB#54
Seems it's safe to just cast to void*.

@nenad
Copy link
Contributor Author

nenad commented Aug 3, 2019

@anacrolix Please review when you have the time.

@anacrolix
Copy link
Owner

Maybe it would be better to push something upstream for this, or alter the C++ compilation flags?

@nenad
Copy link
Contributor Author

nenad commented Aug 5, 2019

Just submitted this PR to upstream: bittorrent/libutp#121

I played with the build flags, but I couldn't get rid of the warning 🤷‍♂️

Should I close this PR?

@anacrolix
Copy link
Owner

Leave it open. The warnings aren't desirable, so we can track fixing them here.

@anacrolix
Copy link
Owner

Thanks for your effort on this @nenad . If we can't get any movement upstream, I'll try it out here.

@anacrolix anacrolix mentioned this pull request Jun 15, 2020
@anacrolix anacrolix merged commit b194960 into anacrolix:master Jan 6, 2021
@anacrolix anacrolix linked an issue Jan 6, 2021 that may be closed by this pull request
@anacrolix
Copy link
Owner

I got impatient with upstream, and was able to reproduce the warnings while cross compiling for a project. Thanks for your patience @nenad .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

varnings
2 participants