Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-01-28 10:07:45


Sebastian Redl <sebastian.redl_at_[hidden]> writes:

> Whatever. Different workaround is to modify
> boost/iterator/iterator_adaptor.hpp:
>
> + #if defined(BOOST_MSVC)
> + #pragma warning(disable: 4244)
> + #endif
> void advance(typename super_t::difference_type n)
> {
>
> BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
> m_iterator += n;
> }
> + #if defined(BOOST_MSVC)
> + #pragma warning(default: 4244)
> + #endif
>
> This is potentially unsafe, of course - nothing prevents you from just
> passing a HUGE value to +=. The likelyhood, though ... well, it's just a
> workaround.

No static checking (e.g. warning) can protect you from the possibility
of runtime overflows in integer operations. The overflow can occur
with or without the warning disabled.

These "integer size warnings" are nothing more than a nuisance in most
generic code. IMO they should be turned off on the command line.
Turning them off in individual source files leaves them cluttered with
workarounds and #ifdefs.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net