From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a9b0810d3106d9b8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news2.google.com!news.glorb.com!news-out.readnews.com!transit3.readnews.com!s09-10.readnews.com!not-for-mail Date: Thu, 28 Apr 2011 09:41:57 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Fun with C References: <4dab6906$0$6893$9b4e6d93@newsspool2.arcor-online.net> <57a1fa4b-4730-41a8-be8a-82061ef9dc22@x37g2000prb.googlegroups.com> <4daca6ba$0$6773$9b4e6d93@newsspool3.arcor-online.net> <33973ba6-c390-4af1-9116-6facb12e2878@u12g2000vbf.googlegroups.com> <4dad9c1b$0$6875$9b4e6d93@newsspool2.arcor-online.net> <0ee0dce3-9121-4af2-9c54-cd15264969ff@t19g2000prd.googlegroups.com> <4db07e47$0$6771$9b4e6d93@newsspool3.arcor-online.net> <4db085b6$0$26801$882e7ee2@usenet-news.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4db96f08$0$12042$882e7ee2@usenet-news.net> NNTP-Posting-Host: e1f0a493.usenet-news.net X-Trace: DXC=NO65LO4?ab;Sa:gN]0eSOA6jO>i5elk8Ef@>Zh> X-Complaints-To: abuse@usenet-news.net Xref: g2news2.google.com comp.lang.ada:20044 Date: 2011-04-28T09:41:57-04:00 List-Id: On 4/28/2011 1:13 AM, David Thompson wrote: > On Thu, 21 Apr 2011 15:27:40 -0400, Hyman Rosen > wrote: >> That doesn't work for C because a variable of an enum type >> may hold any integer value up to the number of bits taken >> by the largest enumerator (with a variation for negatives >> that isn't important here). The C enum concept is meant to >> encompass literals used as bit masks as well as singular >> values. > > s/up to/up to at least/ C++ restricts the permitted values, as per 7.2/6: For an enumeration where e{min} is the smallest enumerator and e{max} is the largest, the values of the enumeration are the values of the underlying type in the range b{min} to b{max}, where b{min} and b{max} are, respectively, the smallest and largest values of the smallest bit-field that can store e{min} and e{max}. On a two's-complement machine, b{max} is the smallest value ≥ max(|e{min}|-1,|e{max}|) of the form 2**M-1; b{min} is 0 if e{min} ≥ 0 and -(b{max}+1) otherwise.