Boost C++ Libraries: Ticket #6922: gcc -Wcast-align warning in boost/intrusive https://svn.boost.org/trac10/ticket/6922 <p> When I tried to use boost::intrusive::set with a member hook, I got this warning (I use reasonably aggressive warning settings): </p> <p> ../../Boost/boost/intrusive/detail/parent_from_member.hpp:50:9: error: cast from 'char *' to 'CSBuilder::Project *' </p> <blockquote> <p> increases required alignment from 1 to 8 [-Werror,-Wcast-align] </p> <blockquote> <p> return (Parent*)((char*)member - offset_from_pointer_to_member(ptr_to_member)); </p> </blockquote> </blockquote> <p> I didn't dig into that code, but judging from the identifiers it seems to do the right thing, and it would seem that the warning is not caused by me doing something bad (unless you count using boost or enabling warnings as 'bad'). Thus, suppressing the warning is probably ok. Just insert an additional (void*) cast like this: </p> <p> return (Parent*)(void*)((char*)member... </p> <p> If other compilers "see through" that and still issue such warnings, somebody with more compiler-experience can probably come up with a better way. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6922 Trac 1.4.3 Ion Gaztañaga Thu, 12 Jul 2012 08:38:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6922#comment:1 https://svn.boost.org/trac10/ticket/6922#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Thanks for the report, it was corrected in trunk at revision 78588 </p> Ticket