From 2c0288728032bc53a3d935553e4b7f840cb3fedc Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Thu, 9 Oct 2025 09:48:12 +1100 Subject: [PATCH] [orc-rt] Enable SPS transparent conversion for reference arguments. Ensures that SPS transparent conversion will apply to arguments passed by reference. --- orc-rt/include/orc-rt/SPSWrapperFunction.h | 3 ++- orc-rt/unittests/SPSWrapperFunctionTest.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/orc-rt/include/orc-rt/SPSWrapperFunction.h b/orc-rt/include/orc-rt/SPSWrapperFunction.h index 5cf387345e6ba..c48694c6d2bfc 100644 --- a/orc-rt/include/orc-rt/SPSWrapperFunction.h +++ b/orc-rt/include/orc-rt/SPSWrapperFunction.h @@ -102,7 +102,8 @@ template struct WFSPSHelper { public: template std::optional serialize(ArgTs &&...Args) { - return serializeImpl(Serializable::to(std::forward(Args))...); + return serializeImpl( + Serializable>::to(std::forward(Args))...); } template diff --git a/orc-rt/unittests/SPSWrapperFunctionTest.cpp b/orc-rt/unittests/SPSWrapperFunctionTest.cpp index 654d86ef26081..d0f06e8d31451 100644 --- a/orc-rt/unittests/SPSWrapperFunctionTest.cpp +++ b/orc-rt/unittests/SPSWrapperFunctionTest.cpp @@ -190,6 +190,17 @@ TEST(SPSWrapperFunctionUtilsTest, TransparentConversionPointers) { EXPECT_EQ(P, &X); } +TEST(SPSWrapperFunctionUtilsTest, TransparentConversionReferenceArguments) { + int X = 42; + int *P = nullptr; + SPSWrapperFunction::call( + DirectCaller(nullptr, round_trip_int_pointer_sps_wrapper), + [&](Expected R) { P = cantFail(std::move(R)); }, + static_cast(&X)); + + EXPECT_EQ(P, &X); +} + static void expected_int_pointer_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx, orc_rt_WrapperFunctionReturn Return,