linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02026
[Bug 518165] Re: Compiling DC++ in release mode (-O2) with g++ 4.4 spews type-punning/aliasing warnings
** Changed in: dcplusplus
Status: Confirmed => Fix Released
--
Compiling DC++ in release mode (-O2) with g++ 4.4 spews type-punning/aliasing warnings
https://bugs.launchpad.net/bugs/518165
You received this bug notification because you are a member of
Dcplusplus-team, which is subscribed to DC++.
Status in DC++: Fix Released
Bug description:
They're mostly in include files, so they keep occurring and swamping any other warnings' visibilities. There's always -fno-string-aliasing but http://gcc.gnu.org/ml/gcc-help/2006-08/msg00240.html makes a good case for their more general danger, that g++ isn't just whinging here. Especially the Tree.h:354 warning and CID.h:41 warnings make it actively harder to take advantage of the diagnostics g++ automatically provides for DC++ code.
This one happens a few times:
In file included from win32\stdafx.h:53:
dwt\include/dwt/widgets/Tree.h: In member function 'dwt::Rectangle dwt::Tree::getItemRect(_TREEITEM*)':
dwt\include/dwt/widgets/Tree.h:354: warning: dereferencing type-punned pointer will break strict-aliasing rules
The line 354 is the TreeView_GetItemRect line in:
inline Rectangle Tree::getItemRect(HTREEITEM item) {
RECT rc;
TreeView_GetItemRect(handle(), item, &rc, TRUE);
return Rectangle(rc);
}
This one happens dozens of times, because CID.h is such a central file:
dcpp\CID.h: In member function 'size_t dcpp::CID::toHash() const':
dcpp\CID.h:41: warning: dereferencing type-punned pointer will break strict-aliasing rules
Line 41: size_t toHash() const { return *reinterpret_cast<const size_t*>(cid); }
This pair comes up less frequently, but still a few times:
dcpp\HashValue.h:52: warning: dereferencing type-punned pointer will break strict-aliasing rules
dcpp\HashValue.h:52: warning: dereferencing pointer '<anonymous>' does break strict-aliasing rules
The line in question is the operator() declaration&definition:
template<typename T>
struct hash<dcpp::HashValue<T> > {
size_t operator()(const dcpp::HashValue<T>& rhs) const { return *(size_t*)rhs.data; }
};
This one is unique to DateTime.cpp:
dwt\src\util\DateTime.cpp: In function 'dwt::util::DateTime dwt::util::operator+(const dwt::util::Da
teTime&, const dwt::util::TimeSpan&)':
dwt\src\util\DateTime.cpp:173: warning: dereferencing type-punned pointer will break strict-aliasing rules
dwt\src\util\DateTime.cpp: In function 'dwt::util::DateTime dwt::util::operator-(const dwt::util::DateTime&, const dwt::util::TimeSpan&)':
dwt\src\util\DateTime.cpp:188: warning: dereferencing type-punned pointer will break strict-aliasing rules
dwt\src\util\DateTime.cpp:192: warning: dereferencing pointer 'tmpVal' does break strict-aliasing rules
dwt\src\util\DateTime.cpp:188: note: initialized from here
dwt\src\util\DateTime.cpp: In function 'dwt::util::DateTime dwt::util::operator+(const dwt::util::DateTime&, const dwt::util::TimeSpan&)':
dwt\src\util\DateTime.cpp:177: warning: dereferencing pointer 'tmpVal' does break strict-aliasing rules
dwt\src\util\DateTime.cpp:173: note: initialized from here
Not going to copy/paste all of that code, but it's generically similar to that already shown.