Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Warning (level 1) C4806
Collapse the table of content
Expand the table of content

Compiler Warning (level 1) C4806

Error Message

'operation' : unsafe operation: no value of type 'type' promoted to type 'type' can equal the given constant

This message warns against code such as b == 3, where b has type bool. The promotion rules cause bool to be promoted to int. This is legal, but it can never be true. The following sample generates C4806:

// C4806.cpp
// compile with: /W1
int main()
{
   bool b = true;
   // try..
   // int b = true;

   if (b == 3)   // C4806
   {
      b = false;
   }
}

Community Additions

ADD
Show:
© 2015 Microsoft