[Bug c++/46732] Valgrind emits false(?) alarms on boost::make_shared

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 1 14:03:00 GMT 2010


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46732

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-01 14:03:39 UTC ---
(In reply to comment #4)
> GCC 4.4 predates that issue being resolved, so the only real workaround is to
> avoid using -std=c++0x with GCC 4.4

Or do something like I did for std::move in my initial implementation of
std::future, which returned scalars by value rather than by rvalue-reference:

  // workaround for CWG issue 664 and c++/34022
  template<typename _Result, bool = is_scalar<_Result>::value>
    struct _Move_future_result
    {
      typedef _Result&& __rval_type;
      static _Result&& _S_move(_Result& __res) { return std::move(__res); }
    };

  // specialization for scalar types returns rvalue not rvalue-reference
  template<typename _Result>
    struct _Move_future_result<_Result, true>
    {
      typedef _Result __rval_type;
      static _Result _S_move(_Result __res) { return __res; }
    };

Boost could use something like this (for GCC 4.4 with -std=c++0x only) to avoid
the problem



More information about the Gcc-bugs mailing list