This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: (minor) cgragph: dependence upon static variable's initial value?
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Gary Funck <gary at intrepid dot com>
- Cc: Gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 14 Sep 2009 11:54:55 +0200
- Subject: Re: (minor) cgragph: dependence upon static variable's initial value?
- References: <20090914021924.GI7654@intrepid.com>
On Mon, Sep 14, 2009 at 4:19 AM, Gary Funck <gary@intrepid.com> wrote:
>
> While reviewing cgraph_analyze_functions() that
> it may depend upon the initial value of two
> static variables, being zero (or at least a value
> that doesn't match a particular address value).
>
> The diff below, shows both the code, and a
> suggested fix:
In C static variables are zero-initialized, so the patch is not
necessary.
Richard.
> Index: cgraphunit.c
> ===================================================================
> --- cgraphunit.c ? ? ? ?(revision 151679)
> +++ cgraphunit.c ? ? ? ?(working copy)
> @@ -907,9 +907,9 @@ cgraph_analyze_functions (void)
> ?{
> ? /* Keep track of already processed nodes when called multiple times for
> ? ? ?intermodule optimization. ?*/
> - ?static struct cgraph_node *first_analyzed;
> + ?static struct cgraph_node *first_analyzed = NULL;
> ? struct cgraph_node *first_processed = first_analyzed;
> - ?static struct varpool_node *first_analyzed_var;
> + ?static struct varpool_node *first_analyzed_var = NULL;
> ? struct cgraph_node *node, *next;
>
> ? process_function_and_variable_attributes (first_processed,
>
>
> ---
>
> I don't know if the initial value of a static variable
> will be zero (NULL) for all implementations, but one
> way/other, it seems clearer to give them a definite
> initial value?
>
>