KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In the following code snippet, the main function calls foo function without any parameter and parenthesis. It is strange that this code can be compiled by gcc. I actually check the assembly code and find out that the compiler just ignore this line. So my question is in which situation this kind of code is used? Or the support of gcc is just a coincidence and actually it is totally useless. int foo(int a,int b) { return a+b; } int main() { foo; // call foo without parameter and parenthesis return 0; } Its assembly code dumped 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)
Tags (comma-separated)
Save Edits
Cancel