MISRAC++2023-0.1.1_b
In this section:
Synopsis
(Advisory) A value should not be unnecessarily written to a local object
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
Found an unused write to an object
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
struct Pair { int a; int b; };
int example()
{
Pair p {};
p.a = 2;
p.a = 3;
return p.a;
}
The following code example passes the check and will not give a warning about this issue:
struct Pair { int a; int b; };
Pair example()
{
Pair p {};
p.a = 2;
p.b = 3;
return p;
}