[Boost-bugs] [Boost C++ Libraries] #13632: boost::function operator== is bugged on FreeBSD 11.2

Subject: [Boost-bugs] [Boost C++ Libraries] #13632: boost::function operator== is bugged on FreeBSD 11.2
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-07-11 13:45:32


#13632: boost::function operator== is bugged on FreeBSD 11.2
------------------------------+----------------------------
 Reporter: hongli@… | Owner: Douglas Gregor
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: function
  Version: Boost 1.67.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------------
 The Passenger application server is a C++ application and uses Boost. Our
 FreeBSD 11.2 users ran into a crash bug:
 https://github.com/phusion/passenger/issues/2097

 Upon further investigation, it turns out that the underlying problem is
 boost::function operator==. The following test program...

 {{{
 boost::function<void ()> f;
 printf("is null: %d\n", f == NULL);
 }}}

 ...prints 1 on macOS (as it should) and 0 on FreeBSD 11.2. I haven't
 tested this small test program on FreeBSD 11.1, but users reported that
 Passenger worked fine on FreeBSD 11.1 so the problem likely did not exist
 there.

 Digger deeper, on FreeBSD the == operator calls this function (in
 boost/function/function_base.hpp):

 {{{
 # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
 // Comparisons between boost::function objects and arbitrary function
 // objects. GCC 3.3 and before has an obnoxious bug that prevents this
 // from working.
 template<typename Functor>
   BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool)
   operator==(const function_base& f, Functor g)
   {
     if (const Functor* fp = f.template target<Functor>())
       return function_equal(*fp, g);
     else return false;
   }
 }}}

 ...and returns false (the else branch).

 While on macOS it calls this function:

 {{{
 inline bool operator!=(const function_base& f,
                        detail::function::useless_clear_type*)
 {
   return !f.empty();
 }
 }}}

 Just looking at the #if there already gives me the feeling that it is not
 right. Boost is trying to work around a GCC 3 bug but it wrongly detects
 Clang 6.0.0 as GCC 3.

 This bug has been confirmed on both Boost 1.64 and Boost 1.67.

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13632>
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 : 2018-07-11 13:50:54 UTC