Address-of and dereference operators cancel each other out

ID

c.maintainability.redundant_pointer_operators

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Redundant Operation

Language

C / C++

Description

This expression applies * and & back to back on the same operand, so one operator cancels the other and the pair has no effect beyond obscuring the intent. Remove the redundant pair and use the plain operand.

Rationale

This expression applies * and & back to back on the same operand, so one operator cancels the other and the pair has no effect beyond obscuring the intent. Remove the redundant pair and use the plain operand.

The following code illustrates the pattern detected by this rule:

void deref_of_address(int x)
{
    // FLAGGED: Address-of and dereference operators cancel each other out
    int y = *&x;
    (void)y;
}

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