lkml.org 
[lkml]   [1998]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 'C' Operators precedence
On Wed, 20 May 1998, Matthew Kirkwood wrote:

> On Wed, 20 May 1998, Richard B. Johnson wrote:
>
> > > And this _without_ optimisation. gcc is right to do this; if a function
> > > clobbers registers, then let it do so when the variables don't contain
> > > anything interersting anyway.
> > >
> > > Your point was..?
> >
> > Sigh. It has nothing to do with clobbering registers. It has to do with
> [snip]
> > printf("%d\n", f() + b + c + d + e );
> > printf("%d\n", b + f() + c + d + e );
> > printf("%d\n", b + c + f() + d + e );
> > printf("%d\n", b + c + d + e + f() );
> > return 0;
> [snip]
> > This will show that the function is always called first, regardless
> > of where it is first seen by the compiler. It must do this because
> > of the reasons previously stated.
>
> By this reasoning, if I'm not much mistaken, it's not actually _possible_
> to compile "f()+f()"...?

It will compile fine. All presidence is satisfied by the completed ()
of both 'f's. Now all we have to do is see if an operand is shared.
If it is. The order of presidence is predetermined as previously
explained. If not, and only if not, the compiler is free to evaluate
the functions in any order.

The above example requires more code to determine..

a = f() + f(); Any order.
a = f() + m + f(); 'm' is shared, the first f() must
be evaluated first, then the second one. This results in:
a = (f()) + (f() + m);

Note that I have deliberately always only used the "+" operator to
demonstrate the point.


Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.101 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:5.833 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site