Warning C6388

'argument' may not be 'value': this does not adhere to the specification for the function 'function-name': Lines: x, y

Remarks

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

Code analysis name: INVALID_PARAM_VALUE_2

Example

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

// C6388_warning.cpp
#include <string.h>
#include <malloc.h>
#include <sal.h>

void DoSomething( _Pre_ _Null_ void* pReserved );

void f()
{
    void* p = malloc( 10 );
    DoSomething( p );  // Warning C6388
    // code...
    free(p);
}

To correct this warning, use the following sample code:

// C6388_no_warning.cpp
#include <string.h>
#include <malloc.h>
#include <sal.h>

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

The use of malloc and free has many pitfalls in terms of memory leaks and exceptions. To avoid these kinds of leaks and exception problems altogether, use the mechanisms that are provided by the C++ Standard Library (STL). These include shared_ptr, unique_ptr, and containers such as vector. For more information, see Smart pointers and C++ Standard Library.