git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git List <git@vger.kernel.org>,
	Thomas Rast <trast@student.ethz.ch>
Subject: Re: [PATCH 3/4] ll-merge: initialize default_opts const
Date: Tue, 15 Nov 2011 23:49:07 -0800	[thread overview]
Message-ID: <7vd3csqzgs.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CALkWK0mVxxq0345B_OJQwejpTBD=evOU_iAv39CvXv4mAi=09A@mail.gmail.com> (Ramkumar Ramachandra's message of "Wed, 16 Nov 2011 11:36:05 +0530")

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> 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?".

  reply	other threads:[~2011-11-16  7:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 1/4] http: remove unused function hex() Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 2/4] convert: don't mix enum with int Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 3/4] ll-merge: initialize default_opts const Ramkumar Ramachandra
2011-11-15 23:17   ` Junio C Hamano
2011-11-16  6:06     ` Ramkumar Ramachandra
2011-11-16  7:49       ` Junio C Hamano [this message]
2011-11-15 16:59 ` [PATCH 4/4] sha1_file: don't mix enum with int Ramkumar Ramachandra
2011-11-15 17:31 ` [PATCH 5/4] git-compat-util: don't assume value for undefined variable Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vd3csqzgs.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=trast@student.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).