HP-UX Cadvise Diagnostics Reference Guide (5900-1865, August 2012)

Table Of Contents
Action:
Check if the constant is expected. In some cases the constant value might be the result of a valid
macro expansion, in such scenarios you can suppress this warning for the particular macro using
the +Wmacro option.
Reference:
4279 the expression depends on order of evaluation
Cause:
The expression modifies a variable more than once without an intervening sequence point OR the
expression modifies a variable and fetches its value in a computation that is not used to 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;
62 Diagnostics Details