views:

76

answers:

1

When I compile on VS 2008 in deubg mode everything works fine. When I compile the same thing in release mode not everything works. As far as I can tell the include directories are the same and there are no additional preprocessor symbols.

Any help?

1>zlib.cpp 1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(419) : error C2664: 'CryptoPP::AllocatorWithCleanup::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup &)' : cannot convert parameter 1 from 'CryptoPP::AllocatorWithCleanup' to 'const CryptoPP::AllocatorWithCleanup &' 1> with 1> [ 1>
T=std::_Aux_cont 1> ] 1>
and 1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ] 1> and 1> [ 1> T=std::_Aux_cont 1>
] 1> Reason: cannot convert from 'CryptoPP::AllocatorWithCleanup' to 'const CryptoPP::AllocatorWithCleanup' 1> with 1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ] 1> and 1> [ 1> T=std::_Aux_cont 1>
] 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(417) : while compiling class template member function 'std::_Container_base_aux_alloc_real<_Alloc>::_Container_base_aux_alloc_real(_Alloc)' 1> with 1> [ 1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector(421) : see reference to class template instantiation 'std::_Container_base_aux_alloc_real<_Alloc>' being compiled 1> with 1>
[ 1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 1> with 1> [ 1> _Ty=CryptoPP::HuffmanDecoder::CodeInfo, 1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ] 1>
C:\myproject\sshlib\zinflate.h(79) : see reference to class template instantiation 'std::vector<_Ty,_Ax>' being compiled 1> with 1>
[ 1>
_Ty=CryptoPP::HuffmanDecoder::CodeInfo, 1>
_Ax=CryptoPP::AllocatorWithCleanup 1> ] 1>zinflate.cpp

The line of code it eventually points to is:

std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue;

Edit: More info:

I get this error exactly when my preprocessor contains NDEBUG instead of _DEBUG. If I change my release config to have _DEBUG isntead it compiles. Why?

+1  A: 

It's a bug in the Visual C++ compiler. See http://old.nabble.com/-jira--Created:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9-Release-mode-td20469700.html.

You can work around it by disabling checked iterators:

#define _SECURE_SCL 0

But be warned: if you link against a third-party library that was compiled with _SECURE_SCL enabled, like e.g. boost, memory corruption can (and will) occur.

Frédéric Hamidi
I am pretty sure I used to have this error, and it went away... after installing a Visual Studio service pack, perhaps? We do work with boost.
Alex Emelianov
Interesting. @MS SQL Server, can you provide the exact version of your compiler?
Frédéric Hamidi
It's the base VS2008 install. I am hoping this is the solution. I'm trying first by applygin 2008 SP1 to see if that works. I'll update the ticket when the install is finished.
MS SQL Server
The flag worked like a charm but I do use boost but it is linked separately, so I'm a little scared. The SP1 itself did nothing to fix the problem. Do I have any other options?
MS SQL Server
Try installing all the updates from [http://update.microsoft.com/](http://update.microsoft.com/). Reboot your machine. Enable checked iterators. Take a deep breath. Rebuild your solution. Keep us posted :)
Frédéric Hamidi