gemini-code-assist[bot] commented on code in PR #48:
URL: https://github.com/apache/tvm-ffi/pull/48#discussion_r2371306756


##########
include/tvm/ffi/container/map.h:
##########
@@ -691,7 +691,7 @@ class DenseMapObj : public MapObj {
   mapped_type& At(const key_type& key) const {

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   There is a const-correctness issue with this method. It is declared `const` 
but returns a non-const reference `mapped_type&`. This allows modification of a 
`const DenseMapObj` through its `at()` method, breaking the const guarantee.
   
   For example:
   ```cpp
   const DenseMapObj my_const_map = ...;
   // This compiles and modifies the const object, which should not be possible.
   my_const_map.at(some_key) = new_value;
   ```
   
   To properly enforce const-correctness, you should consider providing two 
overloads for `At`:
   1. A `const` overload that returns `const mapped_type&`.
   2. A non-`const` overload that returns `mapped_type&`.
   
   This would then be used by the respective `const` and non-`const` `at()` 
public methods. Note that this change might require propagating constness down 
to `ListNode` and its helper methods.



-- 
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