PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page

            bug678.cpp

1     enum color_t { red=1, orange, green, blue };
2
3     struct car
4         {
5         float weight;
6         float length;
7         float width;
8         unsigned passengers:4;
9         unsigned convert:1;
10        unsigned pwr_brake:1;
11        unsigned pwr_steer:1;
12        enum color_t color:2;
13        };
14
15
16    struct car climacto_I;

The programmer is creating a structure to describe an automobile.   What fatal mistake is he or she making?


bug678.cpp lint Output

--- Module:   bug678.cpp
                        _
    enum color_t color:2;
bug678.cpp  12  Warning 678: Member 'car::color' field length (2) too small
    for enum precision (3)
 

Reference Manual Explanation

 
678  Member 'Symbol' field length (Integer) too small for enum precision
     (Integer)  -- A bit field was found to be too small to support all the
     values of an enumeration (that was used as the base of the bit field).
     For example:

                enum color { red, green, yellow, blue };
                struct abc { enum color c:2; };

     Here, the message is not given because the four enumeration values of
     color will just fit within 2 bits. However, if one additional color
     is inserted, Warning 678 will be issued informing the programmer of
     the undesirable and dangerous condition.

Previous Bug - Bug #433 - November 2001

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2003, Gimpel Software