From 5717f4c7d5086c141a957975b6562e589b8080f0 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Sat, 23 Mar 2024 19:11:54 -0400 Subject: [PATCH] Fix reinterpret arrays due to JuliaLang/Julia#51962 --- src/datasets.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/datasets.jl b/src/datasets.jl index 8cc2300cc..e54195285 100644 --- a/src/datasets.jl +++ b/src/datasets.jl @@ -517,6 +517,20 @@ function write_dataset( end end end + +function write_dataset( + dataset::Dataset, + memtype::Datatype, + buf::Base.ReinterpretArray, + xfer::DatasetTransferProperties=dataset.xfer +) where {T} + # We cannot obtain a pointer of a ReinterpretArrayin Julia 1.11 and beyond + # https://github.com/JuliaLang/julia/issues/51962 + buf_copy = copy(buf) + @assert !(typeof(buf_copy) <: Base.ReinterpretArray) "Copying $(typeof(buf)) resulted in another Base.ReinterpretArray" + write_dataset(dataset, memtype, buf_copy, xfer) +end + function write_dataset( dataset::Dataset, memtype::Datatype,