Result of std::move discarded

ID

c.maintainability.discarded_std_move

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Dead Code

Language

C / C++

Description

This call to std::move is a statement on its own: nothing captures the resulting rvalue reference, so the cast has no effect at all. The object is left exactly as it was, and a reader has to stop and check whether a move was actually intended here. Either bind the result (auto moved = std::move(x);), pass it directly to the consumer, or delete the line if it is leftover from a refactor.

Rationale

This call to std::move is a statement on its own: nothing captures the resulting rvalue reference, so the cast has no effect at all. The object is left exactly as it was, and a reader has to stop and check whether a move was actually intended here. Either bind the result (auto moved = std::move(x);), pass it directly to the consumer, or delete the line if it is leftover from a refactor.

The following code illustrates the pattern detected by this rule:

void bug(int v, int w)
{
    // FLAGGED: Result of std::move discarded
    std::move(v);
    (void)w;
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved