Failed assertion dialog box

William M. (Mike) Miller
Fri Nov 13 17:27:57 GMT 2020

I've run into a problem running a collection of tests under Cygwin and I
wonder if anyone can suggest a way around it.

The problem occurs when a program being run fails a C/C++ runtime
assertion. Ordinarily, this just writes an error message on stderr and
aborts. Under Cygwin, however, if both stdin and stderr are redirected to
files, the program instead pops up a dialog box that must be interactively
dismissed before the failed program will exit - holding up all the tests
that follow it.

Specifically, if I have the following as assert.cpp:

    #include <assert.h>
    int main() {

and say

    gcc assert.cpp
    ./a.exe < /dev/null > output 2>&1

I get an error dialog box saying

    Failed assertion
    at line 3 of file assert.cpp
    in function int main()

If I omit either the stdin or the stderr redirection, the program behaves
as desired with no dialog box.

Is there an environment setting or compiler command-line option I can give
to suppress the dialog box and always just write a message to stderr and
abort? Thanks for any insights.

William M. (Mike) Miller | Edison Design Group

More information about the Cygwin mailing list