Partilhar via


C28183

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

warning C28183: The argument could be one value, and is a copy of the value found in the pointer

This warning indicates that this value is unexpected in the current context. This warning usually appears when a NULL value is passed as an argument to a function that does not permit it. The value was actually found in the specified variable, and the argument is a copy of that variable.

The Code Analysis tool reports this warning at the first point where it can definitively determine that the pointer is NULL or that it contains an illegal value. However, it is often the case that the error could actually occur earlier in the trace. When this happens, the Code Analysis tool will also give the line number of the first possible instance -- usually at a location where it could not definitively determine that the warning was appropriate. In those cases, the earlier location where this can occur is appended to the warning message. Typically, a code change should occur at or before that line number, rather than at the point of report.

Example

In the following example, the Code Analysis tool determines that s is NULL in the if statement, and the body of the if is taken. The pointer s is then assigned to t and then t is used in a way where a NULL dereference could occur.

#include <windows.h>  
  
int fun2(char *s)  
{  
    char *t;  
    if (s == NULL) {  
       //... but s is unchanged   
    }  
  
    t = s;  
  
    return lstrlenA(t);  
}  

For this code example, the Code Analysis tool reports the following warning:

d:\sample\testfile.cpp(38) : warning C28183: 't' could be '0', and is a copy of the value found in 's': this does not adhere to the specification for the function 'lstrlenA'.: Lines: 31, 32, 36, 38