Opened 11 years ago

Closed 9 years ago

#6742 closed Bugs (fixed)

C4789 warning using boost range on visual 2010

Reported by: benjamint@… Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.47.0 Severity: Problem
Keywords: range visual C4789 Cc:

Description

Hello,

I am compiling under Windows XP using Visual Studio 2010.

When I use boost::range, I have some strange compilation warning "warning C4789: destination of memory copy is too small".

Here is a small unit test that reproduces this warning:

#define BOOST_TEST_MODULE boost_range_c4789_test

#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/range.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/test/unit_test.hpp>

#include <vector>

/**
   \deftestgroup{boost_range_c4789_test}
   \brief Test a spurious C4789 MSVC warning that happens with boost range
   @{
 **/

 struct FooType
 {
    double a,b;
 };

//-----------------------------------------------------------------------------
/**
   \testdesc The actual test
**/
BOOST_AUTO_TEST_CASE( boost_range_c4789_bug )
{
   using namespace boost::phoenix::arg_names;
   using namespace boost::adaptors;

   FooType foo;
   foo.a = 2.;
   foo.b = -4.;
   size_t numelem = 10;
   std::vector<FooType> foovec(numelem,foo);
   std::vector<double> barvec;

   boost::push_back( barvec, foovec | transformed( (&arg1)->*& FooType::a ) );

   BOOST_CHECK( barvec == std::vector<double>(numelem,foo.a) );
}

///@}

Thanks for your help,

Benjamin.

Change History (2)

comment:1 by Neil Groves, 9 years ago

Status: newassigned

comment:2 by Neil Groves, 9 years ago

Resolution: fixed
Status: assignedclosed

Other fixes appear to have solved this issue. A test case has been added and this compiles cleanly on all platforms available to me (linux with GCC / Clang and OS-X Clang).

Note: See TracTickets for help on using tickets.