HP Code Advisor Diagnostics

produce the modified value without an intervening sequence point. The final value of such
expressions is undefined.
Example:
i = i++; // warning 4279 here
x = i + ++i; // warning 4279 here
i = i + 1; // no warning here
Action:
Rewrite the expression so that each variable is modified only once before a sequence point OR
if a variable is modified, it is fetched only to compute the value to be stored in the variable (ex i
= i+1).
Reference:
C99 6.5, ANSI/ISO C++ 5.4
4281 assignment in control condition
Cause:
An assignment operator = was found where an equality operator == might have been intended,
ex in an if condition expression. While using the assignment operator is valid such expressions
often turn out to be bugs in the user's program.
Example:if (a = b) ...
Action:
Check if the assignment operator is what was intended.
Reference:
4286 return non-const handle to non-public data member may undermine
encapsulation
Cause:
A less-restrictive member function is returning a non-const reference or pointer to a
more-restrictive data member. Since the handle thus returned is not a const, the caller will be
able to modify the restrictive data member, thus violating the norms of encapsulation.
Example:
class Capsule {
public:
int& getvalue_ref() { return private_data; }
int* getvalue_ptr() { return }
private:
int private_data;
} object;
Action:
Declare the member functions to return a const handle instead.
Reference:
4289 endian porting: the definition of the union may be endian dependent
Cause:
The values accessed using the members of a union may differ based on endianness of a machine
on which code is executed. This happens if the union has an integral member, which depends
66 Diagnostics Details