Aracılığıyla paylaş


C6388

warning C6388: <argument> may not be <value>: this does not adhere to the specification for the function <function name>: Lines: x, y

This warning indicates that an unexpected value is being used in the specified context. This is typically reported for values passed as arguments to a function that does not expect it.

Example

The following C++ code generates this warning because DoSomething expects a null value but a potentially non-null value might be passed:

#include <string.h>
#include <malloc.h>
#include <codeanalysis\sourceannotations.h>
using namespace vc_attributes;

void DoSomething( [Pre( Null=Yes )] void* pReserved );
 
void f()
{
    void* p = malloc( 10 );
    DoSomething( p );  // C6388
    // code...
    free(p);
}

To correct this warning, use the following sample code:

#include <string.h>
#include <malloc.h>
#include <codeanalysis\sourceannotations.h>
using namespace vc_attributes;

void DoSomething( [Pre( Null=Yes )] void* pReserved );

void f()
{
  void* p = malloc( 10 );
  if (!p)
  {
    DoSomething( p );  
  }
  else
  {
    // code...
    free(p);
  }
} 

See Also

Concepts

Annotation Overview