Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C26486-Don';是否将可能无效的指针传递给函数?_C++_Pointers_Compiler Warnings - Fatal编程技术网

C++ C26486-Don';是否将可能无效的指针传递给函数?

C++ C26486-Don';是否将可能无效的指针传递给函数?,c++,pointers,compiler-warnings,C++,Pointers,Compiler Warnings,我正在为Windows开发一个内核驱动程序,最近我决定从C转换到C/C++。在代码转换过程中,我遇到了一个无法解决的警告。基本上,我有一个特定代码行的函数: OB_PREOP_CALLBACK_STATUS OCPreOperationCallback( _In_ PVOID RegistrationContext, _Inout_ POB_PRE_OPERATION_INFORMATION OperationInformation ) { // ...

我正在为Windows开发一个内核驱动程序,最近我决定从C转换到C/C++。在代码转换过程中,我遇到了一个无法解决的警告。基本上,我有一个特定代码行的函数:

OB_PREOP_CALLBACK_STATUS
OCPreOperationCallback(
    _In_ PVOID RegistrationContext,
    _Inout_ POB_PRE_OPERATION_INFORMATION OperationInformation
    )
{
    // ...
    auto test = IoThreadToProcess(static_cast<PETHREAD>(OperationInformation->Object));
    // ...
}
在分配之前,但警告仍然存在

我是否遗漏了与此问题相关的内容?

PETHREAD pThread=static\u cast(操作信息->对象);
PETHREAD pThread = static_cast<PETHREAD>(OperationInformation->Object);
if(pThread != nullptr) //or 'pThread != NULL' or 'pThread'
{
   auto test = IoThreadToProcess(pThread);
}
if(pThread!=nullptr)//或'pThread!=NULL'或'pThread' { 自动测试=IoThreadToProcess(pThread); }
对此并不熟悉,但是当您检查
静态\u cast
结果是否为空时会发生什么情况呢?在较新的Visual Studio版本中,静态分析似乎变得过于激进;最近关于假阳性的问题很多。我怀疑这可能是其中之一。你好!谢谢你的回答。不幸的是,您的示例似乎仍然发出警告:。
PETHREAD pThread = static_cast<PETHREAD>(OperationInformation->Object);
if(pThread != nullptr) //or 'pThread != NULL' or 'pThread'
{
   auto test = IoThreadToProcess(pThread);
}