gemini-code-assist[bot] commented on code in PR #78:
URL: https://github.com/apache/tvm-ffi/pull/78#discussion_r2404233601
##########
include/tvm/ffi/optional.h:
##########
@@ -129,7 +129,12 @@ class Optional<T,
std::enable_if_t<!use_ptr_based_optional_v<T> && !std::is_same
* \return the xvalue reference to the stored value.
* \note only use this function after checking has_value()
*/
- TVM_FFI_INLINE T&& operator*() && noexcept { return *std::move(data_); }
+ TVM_FFI_INLINE T&& operator*() && noexcept {
Review Comment:

This function is marked `noexcept`, but it can throw an exception via
`TVM_FFI_THROW`. This will cause `std::terminate` to be called if the optional
is empty. The `noexcept` specifier should be removed to allow the exception to
be thrown and caught properly.
```c
TVM_FFI_INLINE T&& operator*() && {
```
##########
src/ffi/extra/buffer_stream.h:
##########
@@ -67,7 +69,7 @@ class BufferInStream {
bool Read(T* data) {
bool ret = Read(static_cast<void*>(data), sizeof(T)) == sizeof(T); //
NOLINT(*)
if (!TVM_FFI_IO_NO_ENDIAN_SWAP) {
- ByteSwap(&data, sizeof(T), 1);
+ ByteSwap(static_cast<void*>(&data), sizeof(T), 1);
Review Comment:

The call to `ByteSwap` appears to be incorrect. It's byte-swapping the
address of the pointer `data` itself, not the data it points to. It should be
called on `data` directly.
```suggestion
ByteSwap(data, sizeof(T), 1);
```
--
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]