Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Compiler Error C3996

 

annotations that pertain to the value returned by a function should appear at (or near) the start of the declaration

To correct this error

  • In the declaration, put the SAL annotation that corresponds to the return value either directly before the function identifier or before auto.

Example

The following sample generates C3996.

// compile with /analyze

#include <cstdlib>

auto array_alloc(_In_ size_t size) -> _Ret_maybenull_ void *
{
  return malloc(size);
}

Example

The next sample corrects the error.

// compile with /analyze

#include <cstdlib>

auto _Ret_maybenull_ array_alloc(_In_ size_t size) -> void *
{
  return malloc(size);
}
Show: