From: Lang Hames Date: Thu, 13 Apr 2017 05:23:50 +0000 (+0000) Subject: [Orc] Fix bool serialization for RawByteChannels. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e460ede847d024abd43b936a2658df24c5bb243c;p=llvm [Orc] Fix bool serialization for RawByteChannels. The bool type may be larger than the char type, so assuming we can cast from bool to char and write a byte out to the stream is unsafe. Hopefully this will get RPCUtilsTest.ReturnExpectedFailure passing on the bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300174 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h index 39753edaefc..52a546f7c6e 100644 --- a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h +++ b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h @@ -121,11 +121,19 @@ class SerializationTraits::value>::type> { public: static Error serialize(ChannelT &C, bool V) { - return C.appendBytes(reinterpret_cast(&V), 1); + uint8_t Tmp = V ? 1 : 0; + if (auto Err = + C.appendBytes(reinterpret_cast(&Tmp), 1)) + return Err; + return Error::success(); } static Error deserialize(ChannelT &C, bool &V) { - return C.readBytes(reinterpret_cast(&V), 1); + uint8_t Tmp = 0; + if (auto Err = C.readBytes(reinterpret_cast(&Tmp), 1)) + return Err; + V = Tmp != 0; + return Error::success(); } };