[MSVC 7] operator new doesn't throw on failure
----------------------------------------------
Key: STDCXX-79
URL: http://issues.apache.org/jira/browse/STDCXX-79
Project: STDCXX
Type: Bug
Components: External
Versions: 4.1.2
Environment: MSVC 7.0, 7.1
Reporter: Martin Sebor
Priority: Critical
The implementation of operaror new in the MSVC 7 runtime library (but not the
one in the C++ Standard Library, msvcprtd), fails to throw an exception on
failure and instead returns 0. This works correctly in MSVC 8.
Here's a reference to the MSVC 7 documentation of their libraries:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_c_run.2d.time_libraries.asp
$ cat t.cpp && cl /EHsc /MDd t.cpp /c && link /NODEFAULTLIB:msvcprtd t.obj &&
./t
#include <cassert>
#include <new>
#include <crtdbg.h>
int main ()
{
_CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_DEBUG);
_CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_DEBUG);
_CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
int success = 0;
try {
operator new ((unsigned long)-1024);
}
catch (std::bad_alloc&) { success = 1; }
catch (...) { }
assert (success);
}
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
t.cpp
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
Assertion failed: success, file t.cpp, line 20
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira