Date: Fri, 2 Jan 2015 09:41:13 -0500 From: Ed Maste <emaste@freebsd.org> To: David Chisnall <theraven@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: <CAPyFy2B37V8fXDZvEQWZuGNX=n9GSTJG6Vn9pjvCHRm3Xh9vSA@mail.gmail.com> In-Reply-To: <564797DC-A60F-4335-BF74-B8DB4B3AFACA@FreeBSD.org> References: <CEA82F51-9D88-4F20-A649-78AE7E5309AA@lists.zabbadoz.net> <54A61AFD.3040507@multiplay.co.uk> <CAPyFy2CHYiss=OtaeS2MJxqfHz_2fF5MNnQuQFc-rK1cB0Wt%2Bw@mail.gmail.com> <564797DC-A60F-4335-BF74-B8DB4B3AFACA@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2 January 2015 at 04:07, David Chisnall <theraven@freebsd.org> wrote: > > 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-leng= th array. A length-one array was used in C89 prior to this for this purpos= e. 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. I was thinking of making that change, but the driver was not particularly straightforward. In addition to your point about allocation I noticed that it used sizeof() the union containing these variable-length-array structs. I wouldn't want to try to fix it without hardware to test.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2B37V8fXDZvEQWZuGNX=n9GSTJG6Vn9pjvCHRm3Xh9vSA>