MyClass* const Func(const std::string& statename)
for this coverity is giving the error
Parse warning (PW.USELESS_TYPE_QUALIFIER_ON_RETURN_TYPE) type qualifier on return type is meaningless .
Do we really need to remove the const here.?
The warning is correct. The MyClass* const
is not needed. It should be MyClass*
simply. However, you don't need to remove it, but you should remove it.
The reason is, theoretically MyClass* const
would prevent the return value of Func()
from being edited. But that is anyway not editable even without const
, as it's not an lvalue.See the demo here. So with/without const
, the compiler will always generate error, for an attempt to modify the return value of Func()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With