Re: [PATCH] ctype: Fix bitfield types on 16-bit targets
Paul Koning <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
> On Jul 20, 2018, at 1:37 PM, Hans-Bernhard Bröker <[email protected]> wrote: > > Am 20.07.2018 um 13:07 schrieb Sebastian Huber: >> - unsigned int first: 24; - unsigned short delta; + uint_least32_t >> first: 24; + uint_least16_t delta; > > Unfortunately that makes the code's correctness implementation-defined, > because it now depends on what the underlying implementation's take on > the constraint C99 6.7.2.1p4 is: > > A bit-field shall have a type that is a qualified or unqualified > version of _Bool, signed int, unsigned int, or some other > implementation-defined type. > > I.e. compilers are not required to allow uint32_least_t in this place. Yes, but the original code was just as implementation-dependent, because it depended on "int" having at least 24 bits. And indeed that is not true (or not necessarily true) on 16-bit targets. Does "qualified" mean "long int" is allowed? If so, that would be an alternative. But the proposed patch has the advantage that it explicitly calls for a long-enough type. While legally speaking the standard doesn't require that to work, is it plausible that any real world compiler would object? paul