You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2007/08/28 11:03:31 UTC

[jira] Commented: (STDCXX-77) [MSVC 7.1] operator new doesn't throw std::bad_alloc on failure

    [ https://issues.apache.org/jira/browse/STDCXX-77?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523198 ] 

Farid Zaripov commented on STDCXX-77:
-------------------------------------

The possible way (which disables user to use _set_new_handler() and _set_new_mode() functions) is install CRT new handler (using _set_new_handler()) at library initialization and throw std::bad_alloc from there. This way is described here: http://support.microsoft.com/?kbid=167733

> [MSVC 7.1] operator new doesn't throw std::bad_alloc on failure
> ---------------------------------------------------------------
>
>                 Key: STDCXX-77
>                 URL: https://issues.apache.org/jira/browse/STDCXX-77
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 18. Language Support
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4
>         Environment: MSVC 7.1
>            Reporter: Martin Sebor
>            Assignee: Farid Zaripov
>
> $ cat t.cpp && nmake t.exe && ./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) Program Maintenance Utility Version 7.10.3077
> Copyright (C) Microsoft Corporation.  All rights reserved.
>         link  -nologo /NODEFAULTLIB:msvcprtd /debug /LIBPATH:.\..\..\..\..\lib /OUT:t.exe  t.obj  testx15d_msvc_7_1.lib tlt15d_msvc_7_1.lib std15d_msvc_7_1.lib user32.lib
> LINK : LNK6004: t.exe not found or not built by the last incremental link; performing full link
> 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.
-
You can reply to this email to add a comment to the issue online.