A question about expressions...

G

Guest

  When »f(x)« is an expression and »x« is a subexpression, I
  think it is save to say that for each evaluation of »f(x)«,
  the subexpression »x« is evaluated once, ...

How does this fit expressions like »x*x«?
 
K

Keith Thompson

How does this fit expressions like »x*x«?

The expression ``x*x'' has two subexpressions, both of which look
like ``x''. Each of these two subexpressions is evaluated once
during the evaluation of ``x*x''. Unless x is volatile, the compiler
is free to generate code that evaluates x only once (or that doesn't
evaluate the expression at all) -- as long as the result is the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top