Function parameter is reassigned

ID

c.maintainability.avoid_reassigning_parameters

Severity

low

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

low

Resource

Control Flow

Language

C / C++

Description

Parameter $P is reassigned inside the function body. Overwriting a parameter loses the caller’s original argument value and makes the code harder to follow (the name no longer means what was passed in). Introduce a local variable for the modified value and leave the parameter unchanged.

Rationale

Parameter $P is reassigned inside the function body. Overwriting a parameter loses the caller’s original argument value and makes the code harder to follow (the name no longer means what was passed in). Introduce a local variable for the modified value and leave the parameter unchanged.

The following code illustrates the pattern detected by this rule:

int f(int count, int limit, int extra)
{
    // FLAGGED: Function parameter is reassigned
    count = count + 1;
    int local = 0;
    local = 5;
    // FLAGGED: Function parameter is reassigned
    limit = limit - 1;
    // FLAGGED: Function parameter is reassigned
    extra = 0;
    return count + limit + extra + local;
}

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