#158 (with fix) warning C4244: std::ostream::setw() with STLPort

closed-fixed
None
5
2012-12-03
2012-11-18
No

vs2010 with STLPort.5.2.1 and Boost.1_52
XP SP3

error:
ql/math/array.hpp(634): warning C4244: 'argument' : conversion from 'stlpd_std::streamsize' to 'int', possible loss of data
ql/math/array.hpp(635): warning C4244: 'argument' : conversion from 'stlpd_std::streamsize' to 'int', possible loss of data
ql/math/matrix.hpp(584): warning C4244: 'argument' : conversion from 'stlpd_std::streamsize' to 'int', possible loss of data

The fix consists in providing a cast to int because required by STLPort std::ostream::setw() when compiling with vs2010 (and quite probably all others of versions of Microsoft compilers)

So the fixes are:

ql\math\array.hpp : lines 634, 635
#ifdef _STLPORT_VERSION
for (Size n=0; n<a.size()-1; ++n)
out << std::setw((int)width) << a[n] << "; ";
out << std::setw((int)width) << a.back();
#else
for (Size n=0; n<a.size()-1; ++n)
out << std::setw(width) << a[n] << "; ";
out << std::setw(width) << a.back();
#endif

ql\math\matrix.hpp : lines 584
#ifdef _STLPORT_VERSION
for (Size j=0; j<m.columns(); j++)
out << std::setw((int)width) << m[i][j] << " ";
#else
for (Size j=0; j<m.columns(); j++)
out << std::setw(width) << m[i][j] << " ";
#endif

Discussion

  • Luigi Ballabio
    Luigi Ballabio
    2012-12-03

    The patch was applied to the Subversion repository.
    Thank you for the report and the fix.

     
  • Luigi Ballabio
    Luigi Ballabio
    2012-12-03

    • assigned_to: nobody --> lballabio
    • status: open --> closed-fixed