Clan warning meaning "-Wsigned-enum-bitfield"

Please explain to me the meaning of the "-Wsigned-enum-bitfield" Clang warning.

In my code, I have a definition struct

with bit fields:

struct Options {
    BackgroundType backgroundType : 2;
    LineSpace lineSpace : 2;
    bool letterSpacing : 1;
    bool shadow : 1;
    Qt::AlignmentFlag alignment : 9;
} options;

options.alignment = Qt::AlignLeft;

      

When I compile this code with Clang, I get the following warning:

enumerations in the Microsoft ABI are marked with integers by default; consider giving an enum Qt::AlignmentFlag

an unsigned base type to make this code portable

The Enum Qt::AlignmentFlag

is external to my code and I cannot change it. I tend to just ignore this warning. What's the worst that could happen if I leave this code as it is?

+3


source to share


1 answer


If the enum uses all 9 bits, you get a negative number when you read it. If you compare it with any other value, you may run into problems.



+1


source







All Articles