Boost logo

Boost Users :

Subject: [Boost-users] Redefining new, to detect memory leaks, causes issues in boost
From: Lasse Laursen (gazoo_at_[hidden])
Date: 2013-04-12 01:00:38


Hellos,

I recently upgraded to vs2012 and am making liberal use of its leak
detection described here:

http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx

However, I'm running into a spot of trouble. I rely on the C++ style new
commands to allocate memory and as such, I make use of redefining this
call in order to get a specific file and line, at the end of my programs
execution, to where I allocated memory which is leaking. It's super
effective!

According to the link above, the new command is to be redefined thusly:

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

However, boost no likey. I get a syntax error in 'initializer.hpp' at
the following line (122) of code:

new(dest) value_T( boost::detail::variant::move(operand) );

... saying it no longer knows what 'dest' is. A bit puzzling to be
honest. I'm no C++ artisan, so I'm a bit stumped as to how I should
elegantly avoid this issue. I really don't need boost to use this
redefined new, as I'm sure it's as leak proof as can be, but I'm not
sure if it's possible to somehow define my way out of that jam? Or
perhaps change the definition so that the line no longer results in a
syntax error. Any ideas?

Regards,
Lasse


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net