[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] bitfield handling

From: Michael Matz
Subject: Re: [Tinycc-devel] bitfield handling
Date: Sat, 29 Apr 2017 21:31:03 +0200 (CEST)
User-agent: Alpine 2.20 (LSU 67 2015-01-07)


On Fri, 28 Apr 2017, Vicente Bergas wrote:

For example the following does not work:
struct{short x:12; char y:1;}s; s.y=1;

Note that the above is tricky: char can be signed and unsigned if not explicitely specified, and if it's signed then a 1-bit bitfield of char only contains values -1 and 0, so storing a 1 into it actually makes the value be -1. So depending on what you tested that might actually have been the problem. (I.e. always specify signedness of char when using it to store numeric values and not characters).

The attached patch improves bitfield handling.

Yeah, but the bitfield layout involving char fields was actually what was broken. I've fixed that in mob making the above (with 'unsigned char') and ...

There are still corner cases which are still failing, like:
struct{int x:31; char y:2;}s; s.y=1;
in which the char overflows the 32-bit type.

... this work.  Thanks for the report.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]