[comp.lang.c] calling a function without arguments

konath@sj.ate.slb.com (Kannan Konath) (12/22/89)

I have the following program which does not generate any error messages
from the compiler nor does it seem to output any assembly code for
this particular case:

extern void foo();

...


void foo()
{
 ...
 ...
 ...

}


In a later part of the program in some function I call foo:

	foo;

The parenthesis are missing and the compiler does not point this
error out.  It does not seem to generate any assembly code for this 
call to the function (procedure) "foo".

I am compiling the program on a Sun-3 running Sun-OS 4.X and using the 
cc compiler.  

I want to know whether this error should be pointed out by the compiler?

If the answer is no,  what is the reason?

It took me a day or so to spot this error when I tried to set a breakpoint
at this statement in dbxtool which automatically set the breakpoint
at the statement following this one. 

Could you please email me any replies and I will summarize if there is 
interest.

kannan

konath@sj.ate.slb.com

mjones@fenway.uucp (Mike Jones) (12/22/89)

In article <1989Dec22.013757.3086@sj.ate.slb.com> konath@vonneumann.UUCP (Kannan Konath) writes:
>I have the following program which does not generate any error messages
>from the compiler nor does it seem to output any assembly code for
>this particular case:
That's good, as there is no error in your example. Fact is, 
	foo;
is an entirely valid C statement with a different meaning from
	foo();
The first statement will evaluate to the address of foo(), which will
then be thrown away (as you haven't told the compiler to do anything
with it). A warning might be appropriate in this case, but it's
certainly not an error.
Mike Jones		|  When everything has been seen to work, all
AIX Kernel Development	|  integrated, you have four more months work to do.
Kingston, NY		|			- Charles Portman, ICL
	@cs.utexas.edu:ibmchs!auschs!fenway.aix.kingston.ibm.com!mjones