From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl3Xq-00027f-Bb for qemu-devel@nongnu.org; Mon, 25 Nov 2013 16:18:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl3Xk-0004VV-8G for qemu-devel@nongnu.org; Mon, 25 Nov 2013 16:18:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl3Xj-0004VQ-WA for qemu-devel@nongnu.org; Mon, 25 Nov 2013 16:18:08 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAPLI7rq026770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Nov 2013 16:18:07 -0500 Message-ID: <5293BE8C.1060007@redhat.com> Date: Tue, 26 Nov 2013 07:18:04 +1000 From: Richard Henderson MIME-Version: 1.0 References: <1385379990-32093-1-git-send-email-mst@redhat.com> <1385379990-32093-4-git-send-email-mst@redhat.com> <5293B215.4030108@redhat.com> <20131125203152.GB12689@redhat.com> <5293B517.8090108@redhat.com> <20131125205404.GF12689@redhat.com> In-Reply-To: <20131125205404.GF12689@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Paolo Bonzini , qemu-devel@nongnu.org On 11/26/2013 06:54 AM, Michael S. Tsirkin wrote: >>>>> + char s[] = "XXXX"; >>>> >>>> char s[5]; >>>> >> >> Then do something like >> >> char s[sizeof("XXXX")]; >> >> so that the actual initialization doesn't happen. > Why? As an optimization? How about failing to pessimize? With your initialization you're forcing the compiler to do: char s[5]; memcpy(s, "XXXX\0", 5); possibly with the memcpy expanded inline. Since we pass the address of S to vnsprintf, the compiler has to assume that memory is read, and thus the initialization is needed. It can never be optimized away. > I'm not quite sure this doesn't mean we are using VLA which I'd rather not. > Would need to look at language spec ... simple initialization is shorter > and more obviously correct. I'm quite sure that using sizeof does not imply a VLA. r~