nan2088 commented on issue #357:
URL: https://github.com/apache/tvm-ffi/issues/357#issuecomment-3685731601

   > > add a compile-time check and prevent silent overflow
   > 
   > That would make more sense if we check overflow strictly - we used to have 
this check in TVM IIRC. More specifically, you may want to add an `if constexpr 
(Int is uint64)` here:
   > 
   > 
[tvm-ffi/include/tvm/ffi/type_traits.h](https://github.com/apache/tvm-ffi/blob/0d8fec88eca5acaeaa7e771003d183c31711574a/include/tvm/ffi/type_traits.h#L281-L285)
   > 
   > Lines 281 to 285 in 
[0d8fec8](/apache/tvm-ffi/commit/0d8fec88eca5acaeaa7e771003d183c31711574a)
   > 
   >  TVM_FFI_INLINE static void CopyToAnyView(const Int& src, TVMFFIAny* 
result) { 
   >    result->type_index = TypeIndex::kTVMFFIInt; 
   >    result->zero_padding = 0; 
   >    result->v_int64 = static_cast<int64_t>(src); 
   >  } 
   > and if `Int` is `uint64`, it checks overflow
   
   So there are two choices:
   (1) Perform a runtime check, or
   (2) If prevent_u64_overflow=True( or a macro defined), cause load_inline to 
fail at compile time whenever a u64-to-int64 conversion is detected, regardless 
of whether overflow actually occurs.      
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to