[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignm
From: |
Dave Hylands |
Subject: |
RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments |
Date: |
Thu, 9 Dec 2004 17:43:19 -0800 |
Hi wbounce,
> I do not know the inner working of gcc but I disagree with your
> statement
> "The only thing that the language promises is that all side
> effects from
> the expression are completed before the next statement is executed."
>
> In your example
> a = (b = 3) + 4;
> Order of operation requires the following
> Assign 3 to b (because of the ())
> Return 3 from that
> Add 4
> Then assign result (7) to a
>
>
> C DOES have order of operation and operations on the same level are
> supposed to be processed left to right.
This is the classic misunderstanding between precedence and order of
evaluation.
In the statement:
x = f() + g() * h();
We know that the result of f will be added to the product of g times h.
What we don't know is the order that f, g, and h will be called.
In the example I showed, a = ( b = 3 ) + 4; we know that a will be
assigned 7 and b will be assigned 3. We don't know the order that these
assignments will take place in.
It's a similar thing with function calls. We might know the order that
the arguments are pushed on the stack, but we don't know the order that
they will be evaluated in.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments, (continued)
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments, Jeff Barlow, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments, Graham Davies, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments, Jeff Barlow, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments, E. Weddington, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing andport/pinassignments, Graham Davies, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing andport/pinassignments, Jeff Barlow, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing andport/pinassignments, Ben L. Titzer, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessingandport/pinassignments, Graham Davies, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments, Dave Hansen, 2004/12/09
- Re: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments, Julius Luukko, 2004/12/10
RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments,
Dave Hylands <=