![]() | ||||||||||
Messages in this thread |
On 9 Jan 2002, at 19:19, Peter Barada wrote:
>
> >Even
> >
> >int b;
> >volatile const int a = 5;
> >b = a - a;
> >
> >can not be optimized to
> >
> >b = 0;
>
> Until you define the scope of the variables, you can't make that
> assertion. If the code is:
>
> int b;
> volatile const a=5;
> void stuff()
> {
> b = a - a;
> }
>
> I can see how a can change in the midst of the execution since
> some other code has access to a since its global scope.
>
> If the code is:
>
> int b;
> void stuff()
> {
> volatile const a=5;
>
> b = a - a;
> }
>
> Then the code can be optimized to 'b = 0;' since nowhere in the scope
> of 'a' does anyone take its address(which would allow it to be changed).
I could have hardware attached directly to the data bus (a hardware
debugger for instance) that watches for the value 5 to appear. This is
beyond the knowledge of the compiler.
> 2) No one takes the address of b, so there is no way for any external
> hardware/thread to modify b.
see above. You don't need to take the address to catch the variable
access.
MSB
--
Who is this General Failure,
and why is he reading my disk ?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
| |||||||||
| Last update: 2005-03-22 11:15 [W:2.990 / U:0.040 seconds] ©2003-2008 Jasper Spaans | ||||||||||