In the following code fragment, the main function calls the foo function without any parameters and brackets. It is strange that this code can be compiled by gcc. I really check the build code and find out that the compiler is simply ignoring this line. So my question is, in what situation is this type of code used? Or gcc support is just a coincidence, and in fact it is completely useless.
int foo(int a,int b) { return a+b; } int main() { foo;
Its assembly code reset by objdump -d
00000000004004c0 <main>: 4004c0: 55 push %rbp 4004c1: 48 89 e5 mov %rsp,%rbp 4004c4: b8 00 00 00 00 mov $0x0,%eax 4004c9: 5d pop %rbp 4004ca: c3 retq 4004cb: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
source share