bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk 3.1.6: rand.awk test case alignment problem


From: Aharon Robbins
Subject: Re: gawk 3.1.6: rand.awk test case alignment problem
Date: Thu, 24 Apr 2008 17:47:08 +0300

Eric,

You are correct about the semantics of C. Strictly speaking, explicitly
initializing the other element is not necessary, but GCC with a certain
option complains.  It's easy to silence the complaint, which is what
I did. (It also makes for cleaner, more obvious code.)

REMOVING the initializer is wrong: This is an array whose size is
determined based on the number of elements in the initializer, and the
code that uses this array depends on there being a null pointer in the
first field to signal the end of the array.

HTH,

Arnold

> Date: Wed, 23 Apr 2008 21:34:06 -0600
> From: Eric Blake <address@hidden>
> Subject: Re: gawk 3.1.6: rand.awk test case alignment problem
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden
>
> According to Aharon Robbins on 4/23/2008 1:25 PM:
> |> @@ -759,7 +759,6 @@ static struct {
> |>    { ":graph:]", is_graph },
> |>    { ":cntrl:]", is_cntrl },
> |>    { ":blank:]", is_blank },
> |> -  { 0 }
> |>  };
> |
> | The correct fix is actually to supply two zeros in that final initializer,
> | since the code that uses this array does expect there to be a NULL
> pointer in
> | the final element.
>
> Ah, but C guarantees that if you 0-initialize the first element of a
> struct or array, the remaining elements are implicitly 0-initialized.  So
> even though this patch omits the second element of the final struct,
> adding an explicit NULL won't change the behavior.
>
> - --
> Don't work too hard, make some time for fun as well!
>
> Eric Blake             address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]