--- layout: fc_discuss_archives title: Message 21 from Frama-C-discuss on February 2013 ---
On Tue, Feb 19, 2013 at 9:09 AM, Claude Marche <Claude.Marche at inria.fr> wrote: > Notice that it seems that your code relies on the fact that static variables > are initialised to 0. I'm not sure it is guaranteed by the C standard. >From the C11 draft standard of 12 April 2011, Section 6.7.9 (Initialization), paragraph 10: If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static or thread 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 (positive or unsigned) zero; ? if it is an aggregate, every member is initialized (recursively) according to these rules, and any padding is initialized to zero bits; ? if it is a union, the first named member is initialized (recursively) according to these rules, and any padding is initialized to zero bits; >From the draft C89 standard (see http://flash-gordon.me.uk/ansi.c.txt), Section 3.5.7 (Initialization), subsection "Semantics": 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. If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. Regards, -- Jerry James http://www.jamezone.org/