Re: Garbage collection, part two...

From: Erick Gallesio <eg_at_unice.fr>
Date: Thu, 20 Apr 2000 22:46:44 +0200 (CEST)

Felix Lee writes:

> More specifically, 'volatile' tells the compiler that
> factors that the compiler does not know about may read or
> write the variable's value. This means it must avoid
> optimizations and cannot allocate it to a register.
>
> > example such as
> > int var = (int *) A_constant_hardware_address;
> >
> > for (i = 0; i < n; i++)
> > *i = 0;
>
> You mean *var = 0, yes?

Oops yes.
>
> > A clever compiler could replace this by
> > int var = (int *) A_constant_hardware_address;
> > *i = 0;
> > Since doing it n times seems not very useful.
>
> The compiler can't reduce it like that if var is declared
> volatile.

I don't remember that this was clearly stated in the ANSI document (on
which I cannot put a hand). But if it is the case, this is clear that
the current STk code is not valid.


                -- Erick
Received on Thu Apr 20 2000 - 23:19:56 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST