Re: [PATCH 1/7] Rework strbuf API and semantics.

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 1/7] Rework strbuf API and semantics.

From: David Kastrup <hidden>
Date: 2016-06-15 22:43:33

Jeff King [off-list ref] writes:
On Thu, Sep 06, 2007 at 04:44:42PM +0200, David Kastrup wrote:
quoted
quoted
quoted
Would not "struct strbuf sb = { 0 };" have the same effect?  (I am not so 
standards-keen as other people, who I have no doubt will gladly answer 
this one.)
Yes, it would, according to the standard.
Have a citation for that?
Of course.

See ISO 9899:1999, section 6.7.8.

Paragraph 10:

  If an object that has automatic storage duration is not initialized
  explicitly, its value is indeterminate. If an object that has static
  storage duration is not initialized explicitly, then:

  -- if it has pointer type, it is initialized to a null pointer;
That's actually a new one to me.  I don't think that it has been
always the case in ANSI C.

Thanks.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

Re: [PATCH 1/7] Rework strbuf API and semantics.

From: Jeff King <hidden>
Date: 2016-06-15 22:43:33

On Thu, Sep 06, 2007 at 05:06:52PM +0200, David Kastrup wrote:
quoted
  If an object that has automatic storage duration is not initialized
  explicitly, its value is indeterminate. If an object that has static
  storage duration is not initialized explicitly, then:

  -- if it has pointer type, it is initialized to a null pointer;
That's actually a new one to me.  I don't think that it has been
always the case in ANSI C.
I don't have the C89 standard, so it's hard to be authoritative.
However, according to TCOR1 to the C89 standard, the original text of
6.5.7 contained:

  If an object that has static storage duration is not initialized
  explicitly, it is initialized implicitly as if every member that has
  arithmetic type were assigned 0 and every member that has pointer type
  were assigned a null pointer constant.

and was changed to:

  If an object that has static storage duration is not initialized
  explicitly, then:

    - if it has pointer type, it is initialized to a null pointer;

    - if it has arithmetic type, it is initialized to zero;

    - if it is an aggregate, every member is initialized (recursively)
      according to these rules;

    - if it is a union, the first named member is initialized
      (recursively) according to these rules.

But for the case of pointer initializations, both have the same effect.
So I think it has always been the case. Pre-ANSI, who knows. :)

You can find TCOR1 here:

  http://www.open-std.org/jtc1/sc22/wg14/www/docs/tc1.htm

And now I must go get some real work done instead of snooping through
standards. :)

-Peff

Re: [PATCH 1/7] Rework strbuf API and semantics.

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:43:33

David Kastrup schrieb:
Jeff King [off-list ref] writes:
quoted
See ISO 9899:1999, section 6.7.8.

Paragraph 10:

  If an object that has automatic storage duration is not initialized
  explicitly, its value is indeterminate. If an object that has static
  storage duration is not initialized explicitly, then:

  -- if it has pointer type, it is initialized to a null pointer;
That's actually a new one to me.  I don't think that it has been
always the case in ANSI C.
AFAIR, this has always been the case.

-- Hannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help