From: Eric Weddington <[EMAIL PROTECTED]>
> From: Schwichtenberg, Knut [mailto:[EMAIL PROTECTED]
[...]
> Eric, the point is not that I don't like the output, but the
> case to be
> selected should be deterministic. I always thought that a switch
> statement would lead to identical results if the input value is
> identical. This is currently not true. The table jump for a volatile
> variable is identical to an if-then-else structure of a non-volatile
> variable and the current if-then-else implementation for a volatile
> variable can not be simulated by a table jump.
This is one of many reasons why I personally don't like switch statements
in
embedded code. I still suggest coding your algorithm as a dispatch table.
Give it a try.
I think Knut has a point. At least, if I understand what's going on. Given
code like
switch (var)
{
<etc.>
}
If var is volatile, it should be read only once, regarless of the number of
cases. Consider code like
switch (fn())
{
<etc.>
}
How many times would you expect fn to be called?
Of course, a simple workaround would be to read the value of var into a
non-volatile local variable, and switch on that, e.g.,
local = var;
switch (local)
{
<etc.>
}
But he shouldn't _have_ to do that. Bug in gcc?
Regards,
-=Dave
_________________________________________________________________
Get a FREE Web site, company branded e-mail and more from Microsoft Office
Live! http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list