Opened 10 years ago

Closed 10 years ago

#7255 closed Bugs (fixed)

lexical_cast is broken on MSVC .NET 2003

Reported by: Manfred <kuhnkies@…> Owned by: Antony Polukhin
Milestone: Boost 1.52.0 Component: lexical_cast
Version: Boost 1.51.0 Severity: Showstopper
Keywords: MS Secure CRT sprintf_s Cc:

Description

I could not find any hint in the release note that boost 1.51 does no longer support Visual Studio .NET 2003. Hence, I consider the following a (minor) bug. However it causes our project to fail the build on this platform, first time for a reason that I don't consider as "no way out".

author's assumed intention: In boost 1.51 in file boost/lexical_cast.hpp in line 1353 and 1366, 1380 the Microsoft secure crt version sprintf_s of sprintf is called. This call is compiled under the condition that _MSC_VER is defined (with any value!).

presumably unconsidered, severe problem: Please note, that the Microsoft secure crt was introduced with Visual Studio 2005. Visual Studio .NET 2003 does already have _MSC_VER defined. So, the conditional preprocessor instruction "#if(defined _MSC_VER)" imho is ill placed here.

suggestion: I'd like to suggest to consider the numerical values of _MSC_VER here. If _MSC_VER is smaller than 1400 then Visual Studio version is before 8.0 or VS 2005 respectively. Hence I'd appreciate boost code to use a little more complex preprocessor conditional than befor, namely something like

#if _MSC_VER >= 1400

do it the MS Secure CRT Way

#else

ISO C++

#endif

best regards

Manfred

Change History (5)

comment:1 by Manfred <kuhnkies@…>, 10 years ago

Summary: lexical_cast ist broken on MSVC .NET 2003lexical_cast is broken on MSVC .NET 2003

to be more precise: my local patch, that fixes the compile error on MSVC 2003, looks like this:

#if (defined _MSC_VER && _MSC_VER >= 1400)

comment:2 by Antony Polukhin, 10 years ago

Keywords: sprintf_s added
Milestone: To Be DeterminedBoost 1.52.0
Status: newassigned

comment:3 by Antony Polukhin, 10 years ago

(In [80210]) Fix compilation of lexical cast with MSVC 2003 (refs #7255)

comment:4 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)

comment:5 by Antony Polukhin, 10 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.