[Boost-bugs] [Boost C++ Libraries] #6922: gcc -Wcast-align warning in boost/intrusive

Subject: [Boost-bugs] [Boost C++ Libraries] #6922: gcc -Wcast-align warning in boost/intrusive
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-20 21:43:50


#6922: gcc -Wcast-align warning in boost/intrusive
------------------------------------------------------------------+---------
 Reporter: stieber.c@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: intrusive
  Version: Boost 1.49.0 | Severity: Cosmetic
 Keywords: intrusive containers, member hook, alignment warning |
------------------------------------------------------------------+---------
 When I tried to use boost::intrusive::set with a member hook, I got this
 warning (I use reasonably aggressive warning settings):

 ../../Boost/boost/intrusive/detail/parent_from_member.hpp:50:9: error:
 cast from 'char *' to 'CSBuilder::Project *'
       increases required alignment from 1 to 8 [-Werror,-Wcast-align]
         return (Parent*)((char*)member -
 offset_from_pointer_to_member(ptr_to_member));

 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:

 return (Parent*)(void*)((char*)member...

 If other compilers "see through" that and still issue such warnings,
 somebody with more compiler-experience can probably come up with a better
 way.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6922>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC