最佳答案
Instead of 2*i
, I carelessly wrote 2i
:
int foo(int i)
{
2i;
return 2i;
}
I expected the compiler to catch the error. But it did not. So is 2i
a valid statement in C? If so what does it do? Puzzled!
I compiled using gcc version 5.3.0 and here is the assembly output:
.file "strange.c"
.text
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, -4(%rbp)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 5.3.0"
.section .note.GNU-stack,"",@progbits