You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lib/coproc.h:230:46: clearing an object of non-trivial type ‘struct PCI_INFO’; use assignment or value-initialization instead [-Wclass-memaccess]
#3245
In file included from ../lib/gui_rpc_client.h:52,
from screensaver_x11.cpp:41:
../lib/prefs.h: In member function ‘void WEEK_PREFS::clear()’:
../lib/prefs.h:108:43: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct WEEK_PREFS’; use assignment or value-initialization instead [-Wclass-memaccess]
memset(this, 0, sizeof(WEEK_PREFS));
^
../lib/prefs.h:104:8: note: ‘struct WEEK_PREFS’ declared here
struct WEEK_PREFS {
^~~~~~~~~~
Oppie> It's telling you the class is not a plain-old C struct anymore because
you added a constructor. So memset could blow-away your class's data. There
are lots of valid ways to deal with this, including just ignoring the warning.
In general, memset is wrong. But C coders can't let it go. Anyway, here's the
fix:
// bad
memset(&pci_info, 0, sizeof(pci_info));
// good
pci_info = PCI_INFO{};
Hello,
I just backported 7.16.1 and saw myriads of the following compiler warning.
Cheers,
Steffen
The text was updated successfully, but these errors were encountered: