Opened 11 years ago

Last modified 5 years ago

#6525 new Bugs

format atldbgmem.h m_storage VS2010

Reported by: epodkopaev@… Owned by: Fernando Cacciola
Milestone: To Be Determined Component: optional
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

Hi,

Format component of Boost 1.48 doesn't compile with memory debugging enabled in VS2010.

With <atldbgmem.h> included in stdafx.h (precompiled header), compiler says error:

1>d:\boost\boost_1_48_0\boost\optional\optional.hpp(346): error C2061: syntax error : identifier 'm_storage'
1>          d:\boost\boost_1_48_0\boost\optional\optional.hpp(345) : while compiling class template member function 'void boost::optional_detail::optional_base<T>::construct(const std::locale &)'
1>          with
1>          [
1>              T=boost::io::detail::locale_t
1>          ]
1>          d:\boost\boost_1_48_0\boost\optional\optional.hpp(500) : see reference to class template instantiation 'boost::optional_detail::optional_base<T>' being compiled
1>          with
1>          [
1>              T=boost::io::detail::locale_t
1>          ]
1>          d:\boost\boost_1_48_0\boost\format\internals.hpp(56) : see reference to class template instantiation 'boost::optional<T>' being compiled
1>          with
1>          [
1>              T=boost::io::detail::locale_t
1>          ]
1>          d:\boost\boost_1_48_0\boost\format\internals.hpp(57) : see reference to class template instantiation 'boost::io::detail::stream_format_state<Ch,Tr>' being compiled
1>
1>Build FAILED.

The code itself:

#include <boost/format.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
	boost::format fmt("Value: %d\nString: %s\n");
	fmt % 10 % _T("My string");
	printf(fmt.str().c_str());

	return 0;
}

Without atldbgmem.h included the code compiles with no error messages

Regards, Evgeniy

Change History (3)

comment:1 by anonymous, 10 years ago

This is still the case with boost 1.53.0 and VS2012. If I include e.g. boost property tree, and compile in debug mode, I get a

1>c:\boost\boost_1_53_0\boost\optional\optional.hpp(346): error C2061: syntax error : identifier 'm_storage'

I use the following for memory debugging:

#ifdef WIN32
	#include <crtdbg.h>
#endif

#ifdef _DEBUG
	#ifndef DBG_NEW
		#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
		#define new DBG_NEW
	#endif
#endif  // _DEBUG

Without that, or in release mode, it's working fine.

Can we somehow fix this?

comment:2 by dbk25@…, 8 years ago

I have what appears to be a workaround; at least it helped when I hit this problem.

Check whether the #ifdef _DEBUG/#endif that redefines new is before or after the #include <boost/format.hpp>. I hit this problem when new is redefined before including format.hpp, but do not have this problem if new is redefined afterwards. (I'm using a slightly different way to redefine new, but that's most likely not material.)

In other words, this caused the compile error that you are reporting:

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include <boost/format.hpp>

and this worked for me:

#include <boost/format.hpp>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

comment:3 by James E. King, III, 5 years ago

Component: formatoptional
Owner: changed from Samuel Krempp to Fernando Cacciola

This is an issue in Boost.Optional; reassigning.

Note: See TracTickets for help on using tickets.