[RC_1_34_0] Bind warnings

I just started testing the boost 1.34 (RC_1_34_0) cvs branch in our main code line. We're getting a lot of warnings with bind. I'm using Visual Studio 8 SP1. This is a test case that reproduces the warning: #include <boost/bind.hpp> #include <string> class WarningTest { public: WarningTest(void) { boost::bind(&WarningTest::Function, this); } std::string Function() { } }; The warning I get is: WarningTest.cpp c:\msc\ThirdParty\boost_cvs\boost\boost/bind.hpp(1575) : warning C4180: qualifier applied to function type has no meaning; ignored c:\msc\ThirdParty\boost_cvs\boost\boost/bind.hpp(1609) : see reference to class template instantiation 'boost::_bi::add_cref<Pm,I>' being compiled with [ Pm=std::basic_string<char,std::char_traits<char>,std::allocator<char>> (__thiscall WarningTest::* )(void), I=1 ] c:\msc\renal\deliverables source\properties\WarningTest.h(11) : see reference to class template instantiation 'boost::_bi::dm_result<Pm,A1>' being compiled with [ Pm=std::string (__thiscall WarningTest::* )(void), A1=WarningTest * ] I'm not getting these warnings with 1.33. Jared

Jared McIntyre wrote:
I just started testing the boost 1.34 (RC_1_34_0) cvs branch in our main code line. We're getting a lot of warnings with bind. I'm using Visual Studio 8 SP1. This is a test case that reproduces the warning:
#include <boost/bind.hpp> #include <string>
class WarningTest { public: WarningTest(void) { boost::bind(&WarningTest::Function, this); }
std::string Function() { } };
Seems like an annoying compiler bug, not present in 7.1. It's harmless, the compiler just doesn't match the partial specialization whose purpose is to prevent the warning. I'll try to find a workaround, but it might be difficult; compilers seem to have a lot of trouble with deconstructing pointers to member functions (and then putting them back again.) Thank you for the report. Pity that nobody caught that earlier.

Peter Dimov wrote:
Jared McIntyre wrote:
I just started testing the boost 1.34 (RC_1_34_0) cvs branch in our main code line. We're getting a lot of warnings with bind. I'm using Visual Studio 8 SP1. This is a test case that reproduces the warning:
#include <boost/bind.hpp> #include <string>
class WarningTest { public: WarningTest(void) { boost::bind(&WarningTest::Function, this); }
std::string Function() { } };
Seems like an annoying compiler bug, not present in 7.1. [...] Pity that nobody caught that earlier.
One reason that nobody caught it is that it fails only with class/struct return types. Compilers are a lot of fun. Not. Here's a minimal example that demonstrates the issue, if someone would like to take this to MS. As a regression against 7.1, it might receive a priority: template< class Pm > struct add_cref; template< class R, class T > struct add_cref< R (T::*) () > { typedef void type; }; template< class M, class T > typename add_cref< M T::* >::type f( M T::* ) { } struct X { }; struct Z { int f1() { return 0; } X f2() { return X(); } }; int main() { f( &Z::f1 ); // OK f( &Z::f2 ); // fails! }

Peter Dimov <pdimov <at> mmltd.net> writes:
One reason that nobody caught it is that it fails only with class/struct return types. Compilers are a lot of fun.
Not.
Here's a minimal example that demonstrates the issue, if someone would like to take this to MS. As a regression against 7.1, it might receive a priority:
Thanks for looking into this. I can submit it to them when I get in on Monday. I assume you meant to put it against VS8? I only have SP1 at work, did you reproduce this on the base 8.0 release? Jared

Jared McIntyre wrote:
Peter Dimov <pdimov <at> mmltd.net> writes:
One reason that nobody caught it is that it fails only with class/struct return types. Compilers are a lot of fun.
Not.
Here's a minimal example that demonstrates the issue, if someone would like to take this to MS. As a regression against 7.1, it might receive a priority:
Thanks for looking into this. I can submit it to them when I get in on Monday. I assume you meant to put it against VS8? I only have SP1 at work, did you reproduce this on the base 8.0 release?
Yes, it seems to fail on a plain 8.0 as well.

Peter Dimov <pdimov <at> mmltd.net> writes:
Jared McIntyre wrote:
Peter Dimov <pdimov <at> mmltd.net> writes:
One reason that nobody caught it is that it fails only with class/struct return types. Compilers are a lot of fun.
Not.
Here's a minimal example that demonstrates the issue, if someone would like to take this to MS. As a regression against 7.1, it might receive a priority:
Thanks for looking into this. I can submit it to them when I get in on Monday. I assume you meant to put it against VS8? I only have SP1 at work, did you reproduce this on the base 8.0 release?
Yes, it seems to fail on a plain 8.0 as well. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I was curious why this example causes an error in the compiler and the original only causes a warning. Also, would you still like me to put in a support incident on this or has someone else already reported it? Jared

Jared McIntyre <jmcintyre <at> dfsoftware.com> writes:
Peter Dimov <pdimov <at> mmltd.net> writes:
One reason that nobody caught it is that it fails only with class/struct return types. Compilers are a lot of fun.
Not.
Here's a minimal example that demonstrates the issue, if someone
would like
to take this to MS. As a regression against 7.1, it might receive a priority:
Thanks for looking into this. I can submit it to them when I get in on Monday. I assume you meant to put it against VS8? I only have SP1 at work, did you reproduce this on the base 8.0 release?
Jared
Ok, I finally have some information to report back. The issue is definitely a bug in the VS 8 and VS 8 SP1 compilers. Microsoft is now aware of the bug, but does not believe that they will fix it in time for the VS 9 release. Their recommendation is to prewrap the member function in a mem_fn call before the bind: #include <boost/bind.hpp> #include <boost/mem_fn.hpp> #include <string> class WarningTest { public: WarningTest(void) { boost::bind(boost::mem_fn(&WarningTest::Function), this); } std::string Function() { } }; They warn not to trust the compiler without this workaround. They didn't have any suggestions for workarounds in the boost::bind code. Jared
participants (2)
-
Jared McIntyre
-
Peter Dimov