IMO, you are casting too much. size: sizeof(cint) is enough, no need to cast individual elements of the enum. Also use conversion instead of casting when possible.
This works:
type
Enum1* {.size: sizeof(cint), pure.} = enum
p1 = 1, p2 = 2
proc `xor`*(x, y: Enum1): cint =
cint(x) xor cint(y)
let a = Enum1.p1 xor Enum1.p2
type Enum2* {.size: sizeof(cint), pure.} = enum
p2 = Enum1.p1 xor Enum1.p2
p1 = 8,
Run
