`volatile' on local variable used outside of function



Let's say I have a situation like this:

/* begin example.c */
static int* ptr;

static void inner_fn(void)
{
*ptr = 1;
}

void outer_fn(void)
{
int i = 0;
ptr = &i;
inner_fn();
printf("%d\n", i);
}
/* end example.c */

in which a global pointer is set to point to a function-local variable
and then written to in another function. Do I then have to declare `i'
as `volatile' to get the expected behavior?

.



Relevant Pages

  • [git patches] new wireless stuffs
    ... patch with a Linksys WPC11v3. ... All this new wireless code adds near-infinite amounts of trailing whitespace. ... static void timer_func; ... static int takedown_proc_entry(struct net_device *dev, ...
    (Linux-Kernel)
  • Re: gjournal and zfs, questions
    ... It's the same as the other one available from the mailing lists ... this list of conditions and the following disclaimer in the ... +static void putcgs; ...
    (freebsd-questions)
  • [PATCH] 3/5: Device-mapper: snapshots
    ... tristate "Snapshot target " ... +struct disk_exception { ... +static int chunk_io ... +static void persistent_fraction_full(struct exception_store *store, ...
    (Linux-Kernel)
  • [git patches] net drivers build fix, minor updates
    ... struct flash_spec { ... * hw - Struct containing variables accessed by shared code ...
    (Linux-Kernel)
  • [PATCH] Omnikey Cardman 4000 driver
    ... Following-up to the Cardman 4040 driver, I'm now sumitting a driver for ... +static void str_invert_revert ... +static int parse_atr ...
    (Linux-Kernel)