aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/PlainObjectBase.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2011-10-17 08:44:44 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2011-10-17 08:44:44 -0400
commit16b638c159d25991bce2ec85351dc85d1d63c328 (patch)
tree08cd4e5e9fd7469e331a7d895bbb560b29825ca5 /Eigen/src/Core/PlainObjectBase.h
parentdcbc985a2821544f4d035e103494d34972ccf71f (diff)
Throw std::bad_alloc even when exceptions are disabled, by doing new int[size_t(-1)].
Don't throw exceptions on aligned_malloc(0) (just because malloc's retval is null doesn't mean error, if size==0). Remove EIGEN_NO_EXCEPTIONS option, use only compiler standard defines. Either exceptions are enabled or they aren't.
Diffstat (limited to 'Eigen/src/Core/PlainObjectBase.h')
-rw-r--r--Eigen/src/Core/PlainObjectBase.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h
index 11a465c4d..cb28c5795 100644
--- a/Eigen/src/Core/PlainObjectBase.h
+++ b/Eigen/src/Core/PlainObjectBase.h
@@ -37,19 +37,14 @@ namespace internal {
template<typename Index>
void check_rows_cols_for_overflow(Index rows, Index cols)
{
- #ifdef EIGEN_EXCEPTIONS
- // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242
- // we assume Index is signed
- Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed
- bool error = (rows < 0 || cols < 0) ? true
- : (rows == 0 || cols == 0) ? false
- : (rows > max_index / cols);
- if (error)
- throw std::bad_alloc();
- #else
- (void) rows;
- (void) cols;
- #endif
+ // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242
+ // we assume Index is signed
+ Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed
+ bool error = (rows < 0 || cols < 0) ? true
+ : (rows == 0 || cols == 0) ? false
+ : (rows > max_index / cols);
+ if (error)
+ throw_std_bad_alloc();
}
template <typename Derived, typename OtherDerived = Derived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct conservative_resize_like_impl;