Main Content

AUTOSAR C++14 Rule A12-8-5

A copy assignment and a move assignment operators shall handle self-assignment

Description

Rule Definition

A copy assignment and a move assignment operators shall handle self-assignment.

Polyspace Implementation

Reports when copy assignment body does not begin with “if (this != arg)

A violation is not raised if an empty else statement follows the if, or the body contains only a return statement.

A violation is raised when the if statement is followed by a statement other than the return statement.

Troubleshooting

If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Special Member Functions
Category: Required, Automated

Version History

Introduced in R2019a