Table of contents
TOC
Collapse the table of content
Expand the table of content

C28716

Last Updated: 4/22/2017

warning C28716: Compiler-inserted cast between semantically different integral types

This warning indicates that a Boolean is being used as an NTSTATUS without being explicitly cast. This is likely to give undesirable results. For instance, the typical failure value for functions that return a Boolean (false) indicates a success status when tested as an NTSTATUS.

Example

PREfast reports the warning for the following example.

extern bool SomeMemAllocFunction(void **);

return SomeMemAllocFunction(&MyPtr);

The following example avoids the error.

extern bool SomeMemAllocFunction(void **);

if (SomeMemAllocFunction(&MyPtr) == true) {
 return STATUS_SUCCESS;
} else {
 return STATUS_NO_MEMORY;
}

Send comments about this topic to Microsoft

© 2017 Microsoft