diff options
| author | Travis Oliphant <oliphant@enthought.com> | 2006-04-13 01:48:47 +0000 |
|---|---|---|
| committer | Travis Oliphant <oliphant@enthought.com> | 2006-04-13 01:48:47 +0000 |
| commit | 6eec6faa0d5fe660305d5f3014a442eefd0f656d (patch) | |
| tree | 1828717acecd472dfe2089921446186e32603a9f /numpy | |
| parent | 7d03612d28dff126421b2cb19d61622262f63d95 (diff) | |
| download | numpy-6eec6faa0d5fe660305d5f3014a442eefd0f656d.tar.gz | |
Try to fool compilers on in divbyzero generation.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/umathmodule.c.src | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/numpy/core/src/umathmodule.c.src b/numpy/core/src/umathmodule.c.src index e8bf14faf..6490b1aad 100644 --- a/numpy/core/src/umathmodule.c.src +++ b/numpy/core/src/umathmodule.c.src @@ -967,13 +967,17 @@ static void on all the platforms... */ -static int numeric_zero = 0.0; +static int numeric_zero = 0; #if !defined(generate_divbyzero_error) static void generate_divbyzero_error(void) { double dummy; dummy = 1./numeric_zero; - return; + if (dummy) /* to prevent optimizer from eliminating expression */ + return; + else /* should never be called */ + numeric_zero += 1; + return; } #endif @@ -982,6 +986,11 @@ static double numeric_two = 2.0; static void generate_overflow_error(void) { double dummy; dummy = pow(numeric_two,1000); + if (dummy) + return; + else + numeric_two += 0.1; + return; return; } #endif |
