>Author: elemings >Date: Thu May 22 13:54:39 2008 >New Revision: 659253 > >URL: http://svn.apache.org/viewvc?rev=659253&view=rev >Log: >2008-05-22 Eric Lemings <[EMAIL PROTECTED]> > > STDCXX-550
[...] >Modified: stdcxx/branches/4.2.x/util/codecvt.cpp >URL: >http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/codecvt >.cpp?rev=659253&r1=659252&r2=659253&view=diff >=============================================================== >=============== >--- stdcxx/branches/4.2.x/util/codecvt.cpp (original) >+++ stdcxx/branches/4.2.x/util/codecvt.cpp Thu May 22 13:54:39 2008 >@@ -468,29 +468,31 @@ > _RW::__rw_codecvt_t codecvt_out; > std::memset (&codecvt_out, 0, sizeof codecvt_out); > >+#define UINT(x) _RWSTD_STATIC_CAST(unsigned, x) >+ > // calculate byte offsets within the structure > codecvt_out.n_to_w_tab_off = 0; >- codecvt_out.w_to_n_tab_off = codecvt_out.n_to_w_tab_off >- + mbchar_offs.size () * (UCHAR_MAX + 1) * sizeof (unsigned); >+ codecvt_out.w_to_n_tab_off = UINT (codecvt_out.n_to_w_tab_off >+ + mbchar_offs.size () * (UCHAR_MAX + 1) * sizeof (unsigned)); > It seems that the cast should be to the actual destination type instead of `unsigned'. In this case it should be to _RWSTD_UINT32_T. They are potentially different types. A straight function style cast shouldn't be used with that macro because it could be #defined to `unsigned long' which might cause problems. In this case it might be best to write a typedef [UInt32 or _UInt32] and use it [as we do with UChar and _UChar in other parts of the code]. [...] >Modified: stdcxx/branches/4.2.x/util/collate.cpp >URL: >http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/collate >.cpp?rev=659253&r1=659252&r2=659253&view=diff >=============================================================== >=============== >--- stdcxx/branches/4.2.x/util/collate.cpp (original) >+++ stdcxx/branches/4.2.x/util/collate.cpp Thu May 22 13:54:39 2008 >@@ -75,7 +75,7 @@ > > Weights_t* weights = new Weights_t[collate_out_.num_weights]; > >- std::size_t i = 0; >+ int i = 0; > for (i = 0; i < collate_out_.num_weights && w_it != >entry.second.end (); > ++i, ++w_it){ > get_weight (*w_it, weights, i); Doesn't the above change make for a signed/unsigned mismatch? `i' is now signed, but `collate_out_.num_weights is _RWSTD_UINT8_T. >@@ -1179,7 +1179,8 @@ > // check to see of the largest_ce needs to be changed > if (ce_mit->second.ce_wstr.size() + 1 > > collate_out_.largest_ce) >- collate_out_.largest_ce = >ce_mit->second.ce_wstr.size(); >+ collate_out_.largest_ce = >+ unsigned (ce_mit->second.ce_wstr.size()); > The variable `collate_out_.largest_ce' is _RWSTD_UINT8_T. The added cast might fix a 64-bit conversion warning, but is likely to leave behind another truncation warning [on high warning levels] and a signed/unsigned mismatch warning.
