Expression Statements

An expression statement is a legal 'C' expression, followed by a semicolon, ';'. This statement may consist of a single function call, a single assignment, or any complex expression. If the compiler can determine that the expression has no effect, then it will issue a warning and usually will not bother to generate instructions to make the calculation. If the compiler can not see that the statement will have no effect, it must give it the benefit of the doubt and generate the instructions to execute the statement.

Examples of expression statements which do something:

	printf("Why is a disk when it spins?\n");
	x++;
	y=z/3;
	q=(z=5.*x*x)/(w=sqrt(1.+y));

Examples of expression statements which do NOT do anything useful:

	x+5;
	time >= 2300;
	y << z-1;

Note a function call, even if does not return anything, must be assumed to have some side effect and hence must be called.


© 1991-2008 Prem Sobel. All Rights Reserved.