Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55829 - trunk/boost/spirit/home/support/detail/lexer
From: jamin.hanson_at_[hidden]
Date: 2009-08-28 04:10:41


Author: ben_hanson
Date: 2009-08-28 04:10:38 EDT (Fri, 28 Aug 2009)
New Revision: 55829
URL: http://svn.boost.org/trac/boost/changeset/55829

Log:
Prevent overflow in comparison.
Text files modified:
   trunk/boost/spirit/home/support/detail/lexer/consts.hpp | 4 +++-
   1 files changed, 3 insertions(+), 1 deletions(-)

Modified: trunk/boost/spirit/home/support/detail/lexer/consts.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/lexer/consts.hpp (original)
+++ trunk/boost/spirit/home/support/detail/lexer/consts.hpp 2009-08-28 04:10:38 EDT (Fri, 28 Aug 2009)
@@ -22,8 +22,10 @@
 
     const std::size_t max_macro_len = 30;
     const std::size_t num_chars = 256;
+ // If sizeof(wchar_t) == sizeof(size_t) then don't overflow to 0
+ // by adding one to comparison.
     const std::size_t num_wchar_ts =
- (boost::integer_traits<wchar_t>::const_max + 1 < 0x110000) ?
+ (boost::integer_traits<wchar_t>::const_max < 0x110000) ?
         boost::integer_traits<wchar_t>::const_max + 1 : 0x110000;
     const std::size_t null_token = static_cast<std::size_t> (~0);
     const std::size_t bol_token = static_cast<std::size_t> (~1);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk