[previous] 1440 [next] Enum object is being compared with a non-constant, non-enum expression using an equality operator.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

An object of enum type is being compared with the value of a non-constant, non-enum expression using an equality operator. Is this intended ?

For example:


/*PRQA S 2017,2211,2213,3227,3408,3447,3602 ++*/

enum SIZE   { SMALL = 1, MEDIUM = 2, LARGE = 3 };

extern int var;

extern void foo(enum SIZE box)
{
   if (box == var) { }                /* Message 1440 */
   if (box != var) { }                /* Message 1440 */

   if (box >  var) { }                /* Message 1444 */
   if (box <= var) { }                /* Message 1444 */

   return;
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents