Modify

Ticket #7157 (closed Bugs: fixed)

Opened 21 months ago

Last modified 20 months ago

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

Reported by: pavel.korzh@… Owned by: apolukhin
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;
}

Attachments

Change History

comment:1 follow-up: ↓ 2 Changed 21 months ago by apolukhin

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

comment:2 in reply to: ↑ 1 Changed 21 months ago by anonymous

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 Changed 21 months ago by apolukhin

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

comment:4 Changed 21 months ago by apolukhin

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

comment:5 Changed 21 months ago by apolukhin

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from To Be Determined to Boost 1.51.0

comment:6 Changed 21 months ago by apolukhin

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

comment:7 Changed 20 months ago by apolukhin

(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)

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.