views:

92

answers:

1

Using Boost 1.43 and GCC 4.4.3, the following code

boost::bind(&SomeObject::memberFunc, this, _1));

Generates the following warning

boost/function/function_base.hpp:321: warning: dereferencing type-punned pointer will break strict-aliasing rules

What's the correct way to eliminate these warnings without setting -fno-strict-aliasing?

A: 

Are you sure that you've got the right object matched with the class that the member function foo is in? In other words, in the code you posted, is the type of *this the same as SomeObject? Aliasing occurs when the compiler has to track multiple pointers of different types to the same raw data, which is why I suspect that the type of *this and SomeObject are not the same.

sashang
you are the only answer.. congratulations, you win. (the types of *this and SomeObject are the same though.)
Kyle