Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22040

Program executed on Cygwin does not report a thrown exception

$
0
0

When I run a simple program shown below, I get different terminal output on Cygwin and Ubuntu OS.

#include    <cstdio>
#include    <stdexcept>
#include    <cmath>

using namespace std;

double square_root(double x)
{
    if (x < 0)
        throw out_of_range("x<0");

    return sqrt(x);
}

int main() {
    const double input = -1;
    double result = square_root(input);
    printf("Square root of %f is %f\n", input, result);
    return 0;
}

On Cygwin, unlike Ubuntu, I do not get any message indicating that an exception was thrown. What could be the reason for that? Is there something I need to download for Cygwin so that it deals with exceptions as it is supposed to?

I am using Cygwin version 1.7.30 with GCC 4.9.0 . On Ubuntu, I have version 13.10 with GCC 4.8.1 . I doubt that difference in compilers matters in this case.


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>