std::move input may cause a more expensive object
copyConst std::move input cannot be moved and results in more
expensive copy operation
This defect occurs when you use std::move on a const
object, resulting in a more expensive copy operation.
The checker raises a violation only for class types with a nontrivial copy operation and a move operation.
A const object cannot be modified and therefore cannot be moved. An
std::move on a const object silently falls back to a
copy operation without compilation errors. Your code might suffer from poorer performance
without you noticing the issue.
Remove the const qualifier from the object being moved.
If you want a copy operation instead, remove the redundant std::move
call.
Note that this issue also triggers the checker Move operation on const
object, which applies to all move operations on const
objects irrespective of whether the class type has a move operation and a nontrivial copy
operation. If you decide to justify the issue, you can use the same justification for both
results.
Performance improvements might vary based on the compiler, library implementation, and environment that you are using.
| Group: Performance |
| Language: C++ |
| Default: Off |
Command-Line Syntax:
EXPENSIVE_STD_MOVE_CONST_OBJECT |
| Impact: Medium |