Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120208 Thunderbird/10.0.1
On 02/17/2012 10:18 AM, Jim Meyering wrote:
> Bernhard Voelker wrote:
> ...
>>> +static dev_t selinux_challenged_device;
>>
>> Having worked with different compilers, I would rather like to see such
>> variables to be initialized.
> ...
>
> Depending on static-scoped variables to be initialized to 0
> is so fundamental, and has been that way forever, if
> you've seen a compiler that gets it wrong, it could not have
> been good for anything other than (poor) demonstration purposes.
Admitted, you're right.
> In any declaration like "static int VAR = 0;" the "= 0" part is
> strictly optional, even from a let's-be-ultra-portable standpoint.
> At least as far as I know. Can you provide details on a compiler
> that gets that wrong?
I thought I remembered issues on very old machines (~1998),
either a Sun, HP-UX or Sinix, but I don't have access to them
any more. Sinix isn't a supported platform for coreutils anyway,
isn't it?
> You can argue that it makes the code slightly more readable,
> especially if one fails to notice the "static" part.
>
> I just checked and see that there are plenty of instances in coreutils:
>
> git grep -E 'static.* = (0|NULL);'
>
> but most are in the dustier corners, and there are well over 200
> that omit the initializer.
Even if it's not readability, I think it's more about consistency.
Should we remove the instances you found?
Have a nice day,
Berny