Tensor: Fix narrowing-index tests on ILP32 targets
libeigen/eigen!2868 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
co-authored by
Rasmus Munk Larsen
parent
303c4c54db
commit
e82accca02
@@ -86,7 +86,8 @@ static void test_unsigned_dimensions() {
|
||||
|
||||
// A dimension the index type cannot represent must assert rather than silently truncate.
|
||||
static void test_narrowing_dimensions() {
|
||||
VERIFY_RAISES_ASSERT((Eigen::DSizes<int, 3>(2, 3, std::size_t(1) << 40)));
|
||||
// Fixed width: on ILP32 targets shifting std::size_t by 40 is undefined, and GCC folds it to an in-range 0.
|
||||
VERIFY_RAISES_ASSERT((Eigen::DSizes<int, 3>(2, 3, std::uint64_t(1) << 40)));
|
||||
VERIFY_RAISES_ASSERT((Eigen::DSizes<std::ptrdiff_t, 3>(2, 3, std::size_t(-1))));
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,8 @@ static void test_unsigned_indices() {
|
||||
|
||||
// An index the tensor's index type cannot represent must assert rather than silently truncate.
|
||||
static void test_narrowing_indices() {
|
||||
const std::size_t too_large = std::size_t(1) << 40;
|
||||
// Fixed width: on ILP32 targets shifting std::size_t by 40 is undefined, and GCC folds it to an in-range 0.
|
||||
const std::uint64_t too_large = std::uint64_t(1) << 40;
|
||||
|
||||
TensorFixedSize<float, Sizes<2, 3>, ColMajor, int> tensor;
|
||||
tensor.setZero();
|
||||
|
||||
@@ -326,7 +326,8 @@ static void test_unsigned_indices() {
|
||||
|
||||
// An index or dimension the tensor's index type cannot represent must assert rather than silently truncate.
|
||||
static void test_narrowing_indices() {
|
||||
const std::size_t too_large = std::size_t(1) << 40;
|
||||
// Fixed width: on ILP32 targets shifting std::size_t by 40 is undefined, and GCC folds it to an in-range 0.
|
||||
const std::uint64_t too_large = std::uint64_t(1) << 40;
|
||||
|
||||
Tensor<int, 3, ColMajor, int> tensor(2, 3, 7);
|
||||
tensor.setZero();
|
||||
|
||||
@@ -343,7 +343,8 @@ static void test_unsigned_indices() {
|
||||
|
||||
// An index the tensor's index type cannot represent must assert rather than silently truncate.
|
||||
static void test_narrowing_indices() {
|
||||
const std::size_t too_large = std::size_t(1) << 40;
|
||||
// Fixed width: on ILP32 targets shifting std::size_t by 40 is undefined, and GCC folds it to an in-range 0.
|
||||
const std::uint64_t too_large = std::uint64_t(1) << 40;
|
||||
|
||||
Tensor<int, 3, ColMajor, int> tensor(2, 3, 7);
|
||||
tensor.setZero();
|
||||
|
||||
Reference in New Issue
Block a user