Date: Fri, 2 Jan 2015 09:07:13 +0000 From: David Chisnall <theraven@FreeBSD.org> To: Ed Maste <emaste@freebsd.org> Cc: FreeBSD Current <freebsd-current@freebsd.org>, Steven Hartland <killing@multiplay.co.uk> Subject: Re: asr(4) error with new clang/llvm Message-ID: <564797DC-A60F-4335-BF74-B8DB4B3AFACA@FreeBSD.org> In-Reply-To: <CAPyFy2CHYiss=OtaeS2MJxqfHz_2fF5MNnQuQFc-rK1cB0Wt%2Bw@mail.gmail.com> References: <CEA82F51-9D88-4F20-A649-78AE7E5309AA@lists.zabbadoz.net> <54A61AFD.3040507@multiplay.co.uk> <CAPyFy2CHYiss=OtaeS2MJxqfHz_2fF5MNnQuQFc-rK1cB0Wt%2Bw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2 Jan 2015, at 05:00, Ed Maste <emaste@freebsd.org> wrote: >=20 > It's a variable length array in a struct / union. Other than being > confusing and now triggering a warning after the clang update it > should be fine. >=20 > Most likely we need to build asr with -Werror disabled for that > warning, perhaps -Wno-error-array-bounds. I'll take a look tomorrow > morning if nobody else gets to it first. The correct solution is to declare the array to have 0 elements = (although this will break C++ code). A zero-length array at the end of = a structure is specifically defined by the C standard (since C99) to be = a variable-length array. A length-one array was used in C89 prior to = this for this purpose. Using a 1-element array in C is undefined = behaviour. Note that this change will also require fixing code that allocates it to = allocate space for n elements not n-1. David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?564797DC-A60F-4335-BF74-B8DB4B3AFACA>