C6309

更新:2007 年 11 月

警告 C6309:参数 <number> 为 null: 这不符合 <function> 的函数规范

此消息意味着代码将意外的 NULL 参数作为变量传递给指定的 API。将 null 参数传递给接受非 null 参数的函数会导致未处理的异常。

示例

下面的代码生成警告 6309 和 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
}

若要同时更正这两个警告,请使用下面的代码:

#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());
}

请参见

参考

C6387