Opened 9 years ago

Last modified 9 years ago

#9536 new Bugs

narrow-conversion uses insufficient input char type

Reported by: dani@… Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

Test runs exhibit this problem:

compile-c-c++ ..\..\..\bin.v2\libs\date_time\test\teststreams.test\msvc-12.0\debug\address-model-64\posix_time\teststreams.obj
teststreams.cpp
boost/date_time/posix_time/posix_time_legacy_io.hpp(83) : warning C4244: 'argument' : conversion from 'wchar_t' to 'char', possible loss of data
        posix_time\teststreams.cpp(144) : see reference to function template instantiation 'std::basic_istream<wchar_t,std::char_traits<wchar_t>> &boost::posix_time::operator >><wchar_t>(std::basic_istream<wchar_t,std::char_traits<wchar_t>> &,boost::posix_time::time_duration &)' being compiled

The current implementation uses std::stringstream::narrow(char) with its 'char' input parameter type to transform 'charT' chars taken from a std::basic_istream<charT> into 'char' chars. This is most likely not what is intended if 'charT' is wider than 'char'.

Tests were run against Boost version 1.55.0 and latest 'development' branch using vc10, vc11, and vc12. Test logs are attached.

Attachments (1)

date-time-testlogs.7z (22.8 KB ) - added by dani@… 9 years ago.

Download all attachments as: .zip

Change History (2)

by dani@…, 9 years ago

Attachment: date-time-testlogs.7z added

comment:1 by dani@…, 9 years ago

Pull request https://github.com/boostorg/date_time/pull/1 fixes this problem. The attached test logs show the warning is gone now.

Note: See TracTickets for help on using tickets.