[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] [bug #35587] Uninitialized pointer
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-devel] [bug #35587] Uninitialized pointer |
Date: |
Wed, 22 Feb 2012 11:42:42 +0100 |
Mason <address@hidden> wrote:
> > For example MISRA 2004 Rule Number 9.1: "All automatic
> > variables shall have been assigned a value before being used.".
>
> "Automatic" variable is short-hand for automatic storage duration.
> These are so-called "local" variables.
>
> next_timeout, on the other hand, has static storage duration.
>
> cf. 3.1.2.4 Storage durations of objects
Also see ISO9899, 6.7.8 item 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;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
[..]"
Given this, it is of course required to initialize automatic (local) variables,
but static (global) variables *are* initialized by the startup code (if it
follows the standard).
Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de