aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/DenseStorage.h
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-17 22:15:42 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-17 22:15:42 +0100
commitbf7d986af62e3199cccdd79223ff85d384484add (patch)
tree5912a31c520d8708cc93942949762ce44cc38512 /Eigen/src/Core/DenseStorage.h
parente75b1eb883bd65f8f34b1ca2ca13cd28744ab13a (diff)
Add static assert that objects on stacks are not too big (bug #491).
Diffstat (limited to 'Eigen/src/Core/DenseStorage.h')
-rw-r--r--Eigen/src/Core/DenseStorage.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h
index 25fbad1ff..9d34ec934 100644
--- a/Eigen/src/Core/DenseStorage.h
+++ b/Eigen/src/Core/DenseStorage.h
@@ -35,8 +35,16 @@ template <typename T, int Size, int MatrixOrArrayOptions,
struct plain_array
{
T array[Size];
- plain_array() {}
- plain_array(constructor_without_unaligned_array_assert) {}
+
+ plain_array()
+ {
+ EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ }
+
+ plain_array(constructor_without_unaligned_array_assert)
+ {
+ EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ }
};
#ifdef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
@@ -53,8 +61,17 @@ template <typename T, int Size, int MatrixOrArrayOptions>
struct plain_array<T, Size, MatrixOrArrayOptions, 16>
{
EIGEN_USER_ALIGN16 T array[Size];
- plain_array() { EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf) }
- plain_array(constructor_without_unaligned_array_assert) {}
+
+ plain_array()
+ {
+ EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf);
+ EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ }
+
+ plain_array(constructor_without_unaligned_array_assert)
+ {
+ EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ }
};
template <typename T, int MatrixOrArrayOptions, int Alignment>