Why is there a popupwindow for assert(false)

Hello,



This code

#include <cassert>
int main()
{
assert(false);
return 0;
}

compiled like that

"/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 8/VC/BIN/amd64/CL.EXE
-MD -D_CONSOLE -nologo assertion.cpp

produces the output:

Assertion failed: false, file assertion.cpp, line 5
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

and then a popup window appears that tells me that it cannot find the Visual
Studio Just-In-Time Debugger.

HOW CAN I PREVENT THIS POPUP WINDOW

I would not expect this window to pop up, because the MSDN Library
says on the page about assert:

The destination of the diagnostic message depends on the type of application that called the routine. Console applications always receive the message through stderr. In a Windows-based application, assert calls the Windows MessageBox function to create a message box to display the message along with an OK button. When the user clicks OK, the program aborts immediately.

I defined _CONSOLE
I disables just in time debugging in VC++ 2003 and VC8.
I run drwtsn -i so that it sets the registry entries in AeDebug and auto

I've XP64 on an AMD 64

Best regards,

andreas





Answer this question

Why is there a popupwindow for assert(false)

  • S.Bj-m

    This webpage might help.



  • Flippin_Useless


    I followed the link you gave. To me it seems that my problem is the other way round.
    I don't want whatsoever popup window, but just an error report on the console.
    For details, have a look at the non displayed comments at thea above URL.




  • charleste

    I followed option 1, but the problem persists. Note also that I don't have managed
    code.

    any other idea (besides that asserts are a bad idea)

    andreas


  • Hanas

    Hi,

    This is a bug. It has been reported earlier. See http://connect.microsoft.com/feedback/ViewFeedback.aspx FeedbackID=101644&SiteID=210

    Thanks,

    Nikola



  • Stovesy

    Fix the ASSERT! That is the best.

    You can redirect the ASSERT with this to stderr

    _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
    _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );



  • Rateesh

    ASSERT's a a bad thing and should not happen. So the programmer gets the chance in the dialog to break into the debugger to get directly to the location where the assert happens.

    You can use _CrtSetReportMode to change the behaviour.

    http://msdn2.microsoft.com/en-us/library/1y71x448.aspx



  • r2

    Let me recap.

    Its a console application and
    assert(false);
    fails

    Then on the console I get:

    This application has requested the Runtime to terminante it in a unusual way.
    Please contact the applications' support team for more information.

    Then the popup window appears,

    An unhandled win32 exception occured in assertion.exe. Just-In-Time debugging this
    exception failed with the following error: No installed debugger has Just-In-Time-Debugging enabled.....

    When I enable it in Visual Studio, it starts the debugger, so what kind of not works,
    is that Dr Watson (which got registered with drwtsn32.exe) is not considered
    as a good candidate.

    Note that I am on XP64/Turion.



  • Jre1229

    Realize one thing that assert is using for debugging purpose. That's why it's showing source code line numbers and other stuffs. why you need to ignore them


  • dguillory

    Next, try googling for AeDebug...



  • ben999000

    I don't want to ignore asserts. But when they happen they shall report to the console
    not to a popup window, because we run a batch job and not an interactive program


  • Why is there a popupwindow for assert(false)