Unexpected zero return code from `throw std::runtime_error`

Adam Dinwoodie adam@dinwoodie.org
Sat Jul 2 14:29:37 GMT 2022


On Sat, Jul 02, 2022 at 04:14:51PM +0200, Joost Kraaijeveld wrote:
> Hi,
> 
> The exception is not handled by the program. In that case "[[noreturn]]
> void std::terminate()" is called by the C++-runtime. std::terminate
> calls the currently installed std::terminate_handler. The default
> std::terminate_handler calls std::abort. After calling std::abort an
> implementation defined status is returned to the host environment that
> indicates unsuccessful execution.
> 
> So basically both programs do the right thing.

I'm not sure if we're talking at cross purposes here.  My expectation
was exactly what you describe: after hitting the error, I was expecting
to see a non-zero return code from the compiled executable, that being
the expected "implementation defined status ... that indicates
unsuccessful execution".

The problem I am trying to report / get help with is that, in my simple
test case, the exit status is 0, which on Cygwin I would interpret to
mean *successful* execution.


More information about the Cygwin mailing list