Skip to content

Commit 0602574

Browse files
Missed change for ptr in move constructor
1 parent 4232c6e commit 0602574

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/TiledArray/tensor/tensor.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,14 @@ class Tensor {
233233
: range_(std::move(range)), nbatch_(nbatch) {
234234
size_t size = range_.volume() * nbatch;
235235
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
236242
auto* ptr = allocator.allocate(size);
243+
#endif
237244
// default construct elements of data only if can have any effect ...
238245
if constexpr (!std::is_trivially_default_constructible_v<T>) {
239246
// .. and requested

0 commit comments

Comments
 (0)