From owner-freebsd-current@FreeBSD.ORG Fri Jan 2 14:42:42 2015 Return-Path: Delivered-To: freebsd-current@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 03C547C7; Fri, 2 Jan 2015 14:42:42 +0000 (UTC) Received: from mail-ie0-x22e.google.com (mail-ie0-x22e.google.com [IPv6:2607:f8b0:4001:c03::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F5DC1AFB; Fri, 2 Jan 2015 14:41:35 +0000 (UTC) Received: by mail-ie0-f174.google.com with SMTP id at20so16217029iec.5; Fri, 02 Jan 2015 06:41:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=dp/mpy6HfEZnXfk3Czb7ZliN2wt+aI1l/jD4qX1ES5M=; b=d0dJSHqwpXz82pe3T4NUpwli7W6IKoIi4HrtQt9g4BvL2kUSqwr/WUDHSRoiuSBqQH UiRnnnIvr2o9SNdIbX/4DQmAyQ5T75L0UJbUJfQdnTsMaiTibgV/9Lb9a+ZPlgz5xPgQ tDA+DQOyTGTJy41t8X/v95s3bQyzfXfHlbEozpbs9F5L733LuS5DDI+rz2ZhA/jWvz68 UPCipiWSXVy6eQ1hFHa9oxZsqUv8MlUt7WBeMjC1RADluQsE5Sc2Uv8eS4YZmXAIA3cO uvJpx1retzsDSMwIcd+PIFSGQQFpZK53A1PH+gsHmlMd0fLNL7Loc3eWZA44ZYtfnHAr 6KkQ== X-Received: by 10.42.41.146 with SMTP id p18mr56559553ice.52.1420209694257; Fri, 02 Jan 2015 06:41:34 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.0.85 with HTTP; Fri, 2 Jan 2015 06:41:13 -0800 (PST) In-Reply-To: <564797DC-A60F-4335-BF74-B8DB4B3AFACA@FreeBSD.org> References: <54A61AFD.3040507@multiplay.co.uk> <564797DC-A60F-4335-BF74-B8DB4B3AFACA@FreeBSD.org> From: Ed Maste Date: Fri, 2 Jan 2015 09:41:13 -0500 X-Google-Sender-Auth: s369BOneWjJh4j5LEX71mmwxOSQ Message-ID: Subject: Re: asr(4) error with new clang/llvm To: David Chisnall Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Current , Steven Hartland X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jan 2015 14:42:42 -0000 On 2 January 2015 at 04:07, David Chisnall 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.