qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2


From: Richard Henderson
Subject: Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22
Date: Tue, 26 Nov 2013 07:18:04 +1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]