Fix use of alignas(0) which is not ignored on GCC.
- alignas(0) should be ignored, however it results in a build error on
GCC, so instead default to the alignment of double in Jets if
we cannot align to 16-byte boundaries on the platform, but are
compiling with C++11.
Change-Id: I2e54c69516ea2e1447a8bdc138b2dd70050c6dad
diff --git a/include/ceres/jet.h b/include/ceres/jet.h
index e6adaa0..4f517f7 100644
--- a/include/ceres/jet.h
+++ b/include/ceres/jet.h
@@ -244,9 +244,10 @@
16 <= ::ceres::port_constants::kMaxAlignBytes;
static constexpr int kAlignHint = kShouldAlignMatrix ?
Eigen::AutoAlign : Eigen::DontAlign;
- // alignas(0) should always be ignored, in which case this definition of
- // v should be equivalent to the non-C++11 case.
- static constexpr size_t kAlignment = kShouldAlignMatrix ? 16 : 0;
+ // Default to the native alignment of double if 16-byte alignment is not
+ // supported. We cannot use alignof(T) as if we do, GCC complains that the
+ // alignment 'is not an integer constant', although Clang accepts it.
+ static constexpr size_t kAlignment = kShouldAlignMatrix ? 16 : alignof(double);
alignas(kAlignment) Eigen::Matrix<T, N, 1, kAlignHint> v;
#endif
};