#7157 closed Bugs (fixed)
[lexical_cast] convert volatile int to string cause Run-Time Check Failure #2
Reported by: | Owned by: | Antony Polukhin | |
---|---|---|---|
Milestone: | Boost 1.51.0 | Component: | lexical_cast |
Version: | Boost 1.50.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The following code produces a Run-Time Check Failure 2 - Stack around the variable 'buf' was corrupted, if compiled with MSVC2008:
#include "boost/lexical_cast.hpp" int main() { volatile boost::uint32_t n = 10; std::string str = boost::lexical_cast<std::string>(n); return 0; }
Change History (7)
follow-up: 2 comment:1 by , 10 years ago
comment:2 by , 10 years ago
Replying to apolukhin:
Could not reproduce it on MSVC2010. Can you attach more info about this bug (backtrace, line number that triggers this error)
try it on MSVC2008. If you have this one.
compiler didn't find specialization for detail::lcast_src_length so sizeof(buf) is 2 bytes:
std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; // src_len equal 1 here
fix:
< typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay<Source>::type src; --- > typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay<boost::remove_cv<Source>::type>::type src;
comment:5 by , 10 years ago
Milestone: | To Be Determined → Boost 1.51.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:7 by , 10 years ago
(In [80409]) Merge from trunk: 1) #warning replaced with #error (refs #7228) 2) Pavel Korzh added to thanks list (refs #7157) 3) BOOST_NOEXCEPT modifiers added where possible 4) better support for c++11 Unicode characters 5) fixed compilation with MSVC+STLPort 6) more agressive usage of Traits template parameter 7) Added lexical_cast(const CharType* chars, std::size_t count) function overload (refs #6430 and refs #6663) 8) Fixed GCC warning in numeric_cast_test.cpp 9) Fix compilation of lexical cast with MSVC 2003 (refs #7255)
Could not reproduce it on MSVC2010. Can you attach more info about this bug (backtrace, line number that triggers this error)