TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  CFL#017Checked automatically with code checker

Synopsis:Do not make explicit comparisons to true or false
Language:C++
Severity Level:9
Category:Control Flow


Description:

It is usually bad style to compare a bool-type expression to true or false.

It is even dangerous to compare a non-bool-type expression to true: that might unexpectedly evaluate to false.

Example:

while (condition == false)	// wrong; bad style
while (condition == true)	// wrong; possibly dangerous
while (boolean_condition)	// okay if not an assignment, see CFL#011.