Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

C6269

warning C6269: possible incorrect order of operations: dereference ignored

This warning indicates that the result of a pointer dereference is being ignored, which raises the question of why the pointer is being dereferenced in the first place.

The compiler will correctly optimize away the gratuitous dereference. In some cases, however, this defect may reflect a precedence or logic error.

One common cause for this defect is an expression statement of the form:

*p++;

If the intent of this statement is simply to increment the pointer p, then dereference is unnecessary; however, if the intent is to increment the location that p is pointing to, then the program will not behave as intended because *p++ construct is interpreted as * (p++). instead of (*p)++.

The following code generates this warning:

#include <windows.h>

void f( int *p )
{
    // code ...
  if( p != NULL )
    *p++;
    // code ...
}

To correct this warning, use parentheses as shown in the following code:

#include <windows.h>

void f( int *p )
{
    // code ...
  if( p != NULL )
    (*p)++;
    // code ...
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.