Partilhar via


C6282

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 C6282: Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead

This warning indicates that an assignment of a constant to a variable was detected in a test context. Assignment of a constant to a variable in a test context is almost always incorrect. Replace the = with ==, or remove the assignment from the test context to resolve this warning.

Example

The following code generates this warning:

void f( int i )  
{  
   while (i = 5)  
   {  
   // code    
   }  
}  

To correct this warning, use the following code:

void f( int i )  
{  
   while (i == 5)  
   {  
   // code    
   }  
}  

See Also

Compiler Warning (level 4) C4706