about summary refs log tree commit diff stats
path: root/src/ips/serialize.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-03 16:47:20 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-03 16:59:39 +0200
commit519e5fa0986320d55ddcc5c0fa2b8e44dbff779b (patch)
tree43dfbc2c03c3283185688710bad1518ffe136a01 /src/ips/serialize.nim
parentd86abdbfcf081d6a91d0cfc37c5c854527b7b551 (diff)
downloadchawan-519e5fa0986320d55ddcc5c0fa2b8e44dbff779b.tar.gz
Fix CastSize warnings
Introduced by 1.6.14. Warns of undefined behavior.
Diffstat (limited to 'src/ips/serialize.nim')
-rw-r--r--src/ips/serialize.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ips/serialize.nim b/src/ips/serialize.nim
index 54b44a41..9898c0cd 100644
--- a/src/ips/serialize.nim
+++ b/src/ips/serialize.nim
@@ -92,7 +92,9 @@ func slen*(n: SomeNumber): int =
   return sizeof(n)
 
 proc swrite*[T: enum](stream: Stream, x: T) =
-  stream.swrite(cast[int](x))
+  static:
+    doAssert sizeof(int) >= sizeof(T)
+  stream.swrite(int(x))
 
 proc sread*[T: enum](stream: Stream, x: var T) =
   var i: int