Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7157 closed Bugs (fixed)

[lexical_cast] convert volatile int to string cause Run-Time Check Failure #2

Reported by: pavel.korzh@… 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)

comment:1 by Antony Polukhin, 10 years ago

Could not reproduce it on MSVC2010. Can you attach more info about this bug (backtrace, line number that triggers this error)

in reply to:  1 comment:2 by anonymous, 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:3 by Antony Polukhin, 10 years ago

(In [79797]) Fix bug with volatile types (refs #7157)

comment:4 by Antony Polukhin, 10 years ago

(In [79871]) Merge bugfix for volatile types (refs #7157)

comment:5 by Antony Polukhin, 10 years ago

Milestone: To Be DeterminedBoost 1.51.0
Resolution: fixed
Status: newclosed

comment:6 by Antony Polukhin, 10 years ago

(In [79878]) Added notes for lexical_cast library about fixed #7157

comment:7 by Antony Polukhin, 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)

Note: See TracTickets for help on using tickets.