[serialization] basic_binary_oarchive.hpp asserts are no longer necessary

I've just tried building my code against 1.42 and am encountering numerous warnings of the sort: boost/archive/basic_binary_oarchive.hpp:95: warning: comparison is always true due to limited range of data type I've checked the difference to the 1.41 release and noticed that boost/archive/basic_archive.hpp now uses BOOST_ARCHIVE_STRONG_TYPEDEF for class_id_type etc. and uses int_least16_t rather than "int". This is causing my GCC 4.1.2 compiler to produce the above warning because the assertion "t.t <= boost::integer_traits<boost::int_least16_t>::const_max" is always true when t.t *is* an int_least16_t The attached patch removes the (now redundant) asserts.

Number Cruncher wrote:
I've just tried building my code against 1.42 and am encountering numerous warnings of the sort:
boost/archive/basic_binary_oarchive.hpp:95: warning: comparison is always true due to limited range of data type
I've checked the difference to the 1.41 release and noticed that boost/archive/basic_archive.hpp now uses BOOST_ARCHIVE_STRONG_TYPEDEF for class_id_type etc. and uses int_least16_t rather than "int". This is causing my GCC 4.1.2 compiler to produce the above warning because the assertion "t.t <= boost::integer_traits<boost::int_least16_t>::const_max" is always true when t.t *is* an int_least16_t
The attached patch removes the (now redundant) asserts.
I don't see the asserts as redundant. Suppose that one actually uses 32K classes in his program. The program would fail. Of course this is unlikely, but someone could change the type of version type, or int_least16_t could be implemented wrong on some platform or who knows what. If the only issue is the warnings, then a cast inside the assertion would be a better solution. Or maybe using boost::integer_traits<version_type>::const_max - but I don't think that would work. Feel free to make a track item on this. Robert Ramey

On 03/02/10 16:46, Robert Ramey wrote:
I don't see the asserts as redundant. Suppose that one actually uses 32K classes in his program. The program would fail. Of course this is unlikely, but someone could change the type of version type, or int_least16_t could be implemented wrong on some platform or who knows what. If the only issue is the warnings, then a cast inside the assertion would be a better solution. Or maybe using boost::integer_traits<version_type>::const_max - but I don't think that would work. Feel free to make a track item on this.
Fair point. I've amended the patch to check that "t.t" is *less* than the maximum permissible, i.e. we assert if someone gets up to the limit, rather than right on it. This silences GCC for me and is more in keeping with the original spirit of the asserts. Simon.
participants (2)
-
Number Cruncher
-
Robert Ramey