This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: (minor) cgragph: dependence upon static variable's initial value?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]