The value is unused if I use operator overload

Answered

I have the following code, where Handle.operator-> is overloaded, readCount_ is a field in mirror::Object.

If I use this_object->readCount_, CLion reports warning "The value is unused".

 

 

  ALWAYS_INLINE T* operator->() const REQUIRES_SHARED(Locks::mutator_lock_) {
    return Get();
  }

If I use the code inside Handle.operator->, i.e. the Get method, directly, CLion no longer complains.

 

 

Why does using operator-> and Get make a difference?

 

 

0
1 comment

Hello!

It might be related to https://youtrack.jetbrains.com/issue/CPP-7998. Please provide a standalone code snippet in the comments. 

0

Please sign in to leave a comment.