Re: [PATCH 3/4] ll-merge: initialize default_opts const

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

 



Ramkumar Ramachandra <artagnon@xxxxxxxxx> writes:

> Hi Junio,
>
> Junio C Hamano wrote:
>> Ramkumar Ramachandra <artagnon@xxxxxxxxx> writes:
>>> [...]
>>> -     static const struct ll_merge_options default_opts;
>>> +     static const struct ll_merge_options default_opts = {0, 0, 0, 0};
>>
>> Doesn't "static" tell us that it will be in BSS, initialized to all zero
>> by definition?
>
> I'm uncertain about whether the C89 standard says this explicitly- icc
> is more pedantic than most mainstream compilers.

Actually I take a part of the comment back; as this is "static const", it
is entirely plausible for a compiler to tell the linker to put it in rodata
instead of bss, to cause any attempt to modify it to segv.

A datum that is implicitly initialized to all zero and not allowed to be
modified might appear suspect to some compiler writers (especially when
they are under influence ;-)), so I am not so surprised if a compiler
issued a warning saying "did you forget to initialize it?".

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]