Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Why _Bool was not defined as enum in C99? Date: Thu, 15 Sep 2016 13:46:25 -0700 Organization: None to speak of Lines: 42 Message-ID: References: <6b5aa241-0498-4e41-993b-a1ed445effb0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="24704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183YSfzGcn2W1WdQ1EMxNFt" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PeyftX329hND59StvlkpNBIHjMI= sha1:zy8wl/t+00OxSqBgQjOEYlWxKXE= Xref: csiph.com comp.lang.c:93560 supercat@casperkitty.com writes: > On Thursday, September 15, 2016 at 12:52:06 PM UTC-5, Tim Rentsch wrote: >> (Incidentally, I think your statement about enumerated types >> and integer types is not exactly right, because enumerated >> types may not be used as the type specifier for a bitfield, >> even when the compatible integer type could be used instead. >> Of course an enumerated type _Bool could be given a special >> exception for that, as was done for the integer type _Bool in >> C99, but the observation about bitfields does point out a >> difference in the general question.) > > I consider it unfortunate that the authors of the Standard seem averse to > the idea of giving implementations the freedom to accept or reject certain > syntactic forms at their leisure. That would seem to me the best way to > handle constructs that may or may not have enough value to justify making > compiler writers support them. Whether or not the ability to use an > enum bitfield would be sufficiently valuable as to mandate that > implementations must support it, I see nothing to be gained by suggesting > that implementers who want to support it, shouldn't. Congratulations, you have your wish. N1570 6.7.2.1p5: 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. Implementations are free to accept bit-fields of enumerated types, and are not required to diagnose them. (One example: gcc 6.2.0 accepts an enumerated bit field and doesn't warn about it even with "-std=c11 -pedantic -Wall -Wextra".) Please check the standard before complaining about it. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"