Re: [PATCH 3/4] ll-merge: initialize default_opts const
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:29
Ramkumar Ramachandra [off-list ref] writes:
Hi Junio, Junio C Hamano wrote:quoted
Ramkumar Ramachandra [off-list ref] writes:quoted
[...] - 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?".