Re: [PATCH 3/4] ll-merge: initialize default_opts const
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 16, 2011, 07:49 UTC
- Message-ID
- <7vd3csqzgs.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CALkWK0mVxxq0345B_OJQwejpTBD=evOU_iAv39CvXv4mAi=09A@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 13 quoted lines
> Hi Junio,
>
> Junio C Hamano wrote:
>> Ramkumar Ramachandra <artagnon@gmail.com> 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?".