[cfe-dev] different signedness for bitfield 'char' and plain 'char'

Robert Lytton robert at xmos.com
Tue Jul 30 10:51:26 PDT 2013


Hi,

I have altered isSignedCharDefault()  to make 'char' unsigned for the xcore target too.
(The signedness of 'char' is an ABI issue as far a the standard is concerned.)

My problem now is that char-bitfields are also being made unsigned.
According to the standard the members of a bitfield are always signed unless explicitly marked unsigned.

Hence I need:
    'char' to be unsigned.
    but the bit field 'char' to be signed.

viz:
    // ABI requires plain 'char' to be unsigned
    char c = (char)-1;
    assert(c >= 0);

    // members of a bitfield are always signed unless explicitly marked unsigned
    struct char_sign { char x : 1; };
    char_sign.x = 1;
    assert(char_sign.x < 0);


Is this possible in clang?
If not, could anyone like to point me in the right direction to where the fix would be necessary?

Thank you

Robert


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130730/6f068d28/attachment.html>


More information about the cfe-dev mailing list