Re: [Sdcc-user] Erroneous compiler warning

2008-01-29 Thread Mary-Ann Johnson
Thanks, I had indeed misunderstood Ken's point. However, if I change the code thus: --- void func(void) { volatile int timeout; return; timeout = 0x; while (timeout--); } --- the only difference is that the warning is pr

Re: [Sdcc-user] Erroneous compiler warning

2008-01-24 Thread Maarten Brock
Mary-Ann, I think you missed the point Ken Jackson was trying to make. Even if you do NOT insert the return-statement the code can still be optimized out by the compiler because it has no so-called side-effects. Only if you make the timeout variable 'volatile' you disallow the compiler to mak

Re: [Sdcc-user] Erroneous compiler warning

2008-01-24 Thread Mary-Ann Johnson
Yes, I want the compiler to optimise it away, but I'd like it to do so without complaining about the "timeout" variable. The following code has similar problems: void func(void) { return; { int timeout; timeout = 0x; while (timeout--); } } Mary-Ann Ken Jackson wrote: > I

[Sdcc-user] Erroneous compiler warning

2008-01-22 Thread Ken Jackson
I don't know the answer, though I offer an observation. Most compilers will optimize away the delay that you are trying to implement. Therefore you should declare timeout this way: volatile int timeout; Also, when I do it that way, I don't get the warning. -Ken Jackson Mary-Ann Johnson writ

[Sdcc-user] Erroneous compiler warning

2008-01-22 Thread Mary-Ann Johnson
If I compile the following code (SDCC 2.7.0): void func(void) { int timeout; return; timeout = 0x; while (timeout--); } SDCC produces the following warnings: "src/test.c:8: warning 84: