From owner-svn-src-all@FreeBSD.ORG Tue Apr 21 12:40:56 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 80658837; Tue, 21 Apr 2015 12:40:56 +0000 (UTC) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 418031228; Tue, 21 Apr 2015 12:40:55 +0000 (UTC) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id E26CF1047520; Tue, 21 Apr 2015 22:40:51 +1000 (AEST) Date: Tue, 21 Apr 2015 22:40:46 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Bruce Evans , David Chisnall , John Baldwin , Justin Hibbits , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r281721 - head/sys/sys In-Reply-To: <20150421095900.GL2390@kib.kiev.ua> Message-ID: <20150421222539.J2985@besplex.bde.org> References: <201504190033.t3J0XMDX041769@svn.freebsd.org> <476583045.Qcb6O2DFtY@ralph.baldwin.cx> <20150421020808.D10623@besplex.bde.org> <785A553E-317E-4C80-83A0-567C80697ED8@FreeBSD.org> <20150421184157.Y2048@besplex.bde.org> <20150421095900.GL2390@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=L/MkHYj8 c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=yh1_mKi3brNwCaDYqQkA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Apr 2015 12:40:56 -0000 On Tue, 21 Apr 2015, Konstantin Belousov wrote: > On Tue, Apr 21, 2015 at 07:32:30PM +1000, Bruce Evans wrote: >> On Tue, 21 Apr 2015, David Chisnall wrote: >> >>> On 20 Apr 2015, at 17:19, Bruce Evans wrote: >>>> >>>> Enums should never be used in ABIs, since their size can be anything >>>> large enough. >>> >>> The rules for the size of enums also differ between C and C++, though clang (and, I think, gcc) support an attribute for specifying the enum type. >>> >>>> They also cause namespace problems. The whole enum declaration must >>>> be exposed in any header that uses an enum type. >>> >>> Both C and C++ permit forward declarations of enums for use in function prototypes and so on, e.g.: >>> >>> enum foo; >>> void >>> bar(enum foo); >> >> No, they cannot do this since the size may depend on the internals of the >> enum: >> >> TendDRA-5.0.0: >> "z.c", line 1: Error: >> [ISO C90 6.5.2.3]: Can't declare the enumeration 'enum foo'. >> > This is not true for C. The i386 ABI specification, from year _1997_, > states that enum must be 4-bytes unsigned entity, 4-bytes aligned. See page > 28 of abi386-4.pdf. That is only the i386 implementation of C. Good enough for ABI portability. Is it really so broken as to specify unsigned? enum values have type int, so unsigned cannot represent all of them. Unrepresentable enums are detected in all compilers I tested, but the error handling is broken except in gcc: clang-current: z.c:1:29: warning: overflow in enumeration value enum foo { xx = 0x7fffffff, yy }; ^ 1 warning generated. gcc4.2.1: z.c:1: error: overflow in enumeration values TenDRA-5.0.0: trans:/tmp/tccljzRYO/_tcc.t: internal error: constant out of range TendDRA also suffers from the C90 design error of not allowing a comma after yy. It detects this and handles it perfectly brokenly to C90 spec: "z.c", line 1: Error: [Syntax]: Extra comma at end of list. Bruce