We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4232c6e commit 0602574Copy full SHA for 0602574
src/TiledArray/tensor/tensor.h
@@ -233,7 +233,14 @@ class Tensor {
233
: range_(std::move(range)), nbatch_(nbatch) {
234
size_t size = range_.volume() * nbatch;
235
allocator_type allocator;
236
+#if EIGEN_HAS_MAJOR_VERSION_5
237
+ // Eigen >=3.5.0 returns nullptr if size=0
238
+ auto* ptr = (!size && range_.rank())
239
+ ? static_cast<pointer>(std::malloc(size))
240
+ : allocator.allocate(size);
241
+#else
242
auto* ptr = allocator.allocate(size);
243
+#endif
244
// default construct elements of data only if can have any effect ...
245
if constexpr (!std::is_trivially_default_constructible_v<T>) {
246
// .. and requested
0 commit comments