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 16:01:23 -0700 Organization: None to speak of Lines: 48 Message-ID: References: <6b5aa241-0498-4e41-993b-a1ed445effb0@googlegroups.com> <8a299630-42f9-4e6c-bc75-c0327a9b166e@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="U2FsdGVkX19ouKSzKGvSYr3qx+/jC7l9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:txoVDMI4wX8tK6Jl6lIDnVHaAd4= sha1:THOwfND+ThWIibLdt627N7GivUU= Xref: csiph.com comp.lang.c:93578 supercat@casperkitty.com writes: > On Thursday, September 15, 2016 at 1:49:56 PM UTC-5, Keith Thompson wrote: >> supercat writes: >> > 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".) > > Given: > > enum foo { boz,baz; }; > > is the type "foo" defined by the implementation or by user code? Does > anything in the Standard specify that the phrase "Implementation-Defined > type" would be applicable to such an enum? My interpretation (and apparently that of the authors of gcc) is that the implementation is free to specify that bit-fields may be of enumerated types. The phrase "implementation-defined type" doesn't mean that the type itself is necessarily defined by the implementation. It means that the implementation defines which types are permitted. (Of course an implementation is also free to reject enumerated bit-fields.) -- 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"