Opened 9 years ago

Closed 9 years ago

#9621 closed Bugs (fixed)

dynamic_bitset.hpp MSVC compiler warning C4996 in call to std::fill_n

Reported by: Drew Foster <drew.foster@…> Owned by: acharles
Milestone: Boost 1.56.0 Component: dynamic_bitset
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

When using the MSVC 12.0 compiler (and earlier versions) with dynamic_bitset, the following compiler warning is generated...

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2715): warning C4996: 'std::_Fill_n': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2701) : see declaration of 'std::_Fill_n' 1> d:\devel\drew.fosterTfs\3rdParty\Boost\1.54\main\dynamic_bitset\boost/dynamic_bitset/dynamic_bitset.hpp(810) : see reference to function template instantiation '_OutIt std::fill_n<unsigned long*,boost::dynamic_bitset<unsigned long,std::allocator<Block>>::size_type,unsigned long>(_OutIt,_Diff,const _Ty &)' being compiled 1> with 1> [ 1> _OutIt=unsigned long * 1> , Block=unsigned long 1> , _Diff=boost::dynamic_bitset<unsigned long,std::allocator<unsigned long>>::size_type 1> , _Ty=unsigned long 1> ]

As noted in other threads (http://lists.boost.org/Archives/boost/2006/08/109338.php), this is a shortcoming of the Microsoft compiler.

It can be easily fixed by modifying line 810 in dynamic_bitset.hpp to use an iterator for the first parameter instead of a raw pointer in the call to std::fill_n.

  • std::fill_n(b, div, static_cast<block_type>(0));

+ std::fill_n(m_bits.begin(), div, static_cast<block_type>(0));

Change History (6)

comment:1 by acharles, 9 years ago

Owner: changed from jsiek to acharles
Status: newassigned

comment:2 by acharles, 9 years ago

I have a local fix for this, I'll submit a pull request after my current one is accepted.

comment:3 by acharles, 9 years ago

Type: PatchesBugs

comment:4 by acharles, 9 years ago

Milestone: To Be DeterminedBoost 1.56.0

comment:5 by acharles, 9 years ago

Fix is in develop.

comment:6 by acharles, 9 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.