Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

C6309

warning C6309: argument <number> is null: it does not adhere to function specification of <function>

This message indicates that the code is passing an unexpected NULL parameter as an argument to the specified API. Passing a null parameter to a function that expects a non-null parameter can cause unhandled exception.

Example

The following code generates warning 6309 and 6387:

#include <codeanalysis/sourceannotations.h>
using namespace vc_attributes;


void f([Pre(Null=No)] void*);
[returnvalue:Post(Null=Yes)] void* g();

void main()
{
   f(g()); // 6309 and 6387
}

To correct both warnings, use the following code:

#include <codeanalysis/sourceannotations.h>
using namespace vc_attributes;


void f([Pre(Null=No)] void*);
[returnvalue:Post(Null=No)] void* g(); // pointer not null

void main()
{
   f(g());
}

See Also

Reference

C6387

Community Additions

ADD
Show:
© 2015 Microsoft