libutp icon indicating copy to clipboard operation
libutp copied to clipboard

Cast to void

Open nenad opened this issue 6 years ago • 6 comments

Prevent warnings from popping up in GCC >= 8.1

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 {
      |        ^~~~~~~~~~~~

Resolved like in this issue: https://github.com/intel/tbb/issues/54

nenad avatar Aug 05 '19 17:08 nenad

Apologies for breaking the silence :speak_no_evil:. Is the PR good enough to be merged as it is without removing the line?

nenad avatar Aug 12 '19 19:08 nenad

Hi again! I was going through the list of my PRs and I noticed this one hasn't been active for quite some time. Personally, I find warnings in my build logs not pretty, and this PR addresses that issue. Would it be able to get this merged, or should I close it and leave the warnings?

nenad avatar Sep 16 '19 07:09 nenad

Hi, what is the status of this PR pls ? I'm using libutp in golang and that (a small okay but still one) problem, I'm making a lib with it and gcc warning are not a good figure to end user even if there is 5 lib layer between libutp and the end user.

Jorropo avatar Nov 03 '19 21:11 Jorropo

I would approve a PR that removes the memset and adds the static_assert I suggested earlier. nut I don’t have privileges to merge

arvidn avatar Nov 03 '19 21:11 arvidn

Any update on this? Would anyone be willing to merge this?

anacrolix avatar Jun 15 '20 06:06 anacrolix

I do not think this proposed patch is a good solution to the GCC warning. The warning is right, this patch just silences it instead of fixing the code.

arvidn avatar Jun 15 '20 08:06 arvidn