News for hackers. Stuff that matters.
Re:F() vs. F(void) in C vs. C++ by userbinator on Sunday May 12, 2019 @06:48PM (#19895100)
For those who are still wondering the actual reason for the extra instruction after reading all that, it has to do with the calling convention: when calling a variadic function in SysV AMD64, AL holds the number of vector registers used for parameters. I believe the Microsoft x64 one doesn't do that.

Also, a xor r32, r32 is 2 bytes, not 1.

Re:F() vs. F(void) in C vs. C++ by ndesaulniers on Sunday May 12, 2019 @07:17PM (#19895234)
Yep: https://godbolt.org/z/BMjD0Y

sorry, I must've misread the output from godbolt from too many window splits. Will update the article. Thanks for pointing it out. :)

Re:F() vs. F(void) in C vs. C++ by klodolph on Sunday May 12, 2019 @11:30PM (#19896257)
The reason is that there’s no space between the instruction address and the first byte of the instruction, but there are spaces between later bytes.
Re:F() vs. F(void) in C vs. C++ by saagarjha on Sunday May 12, 2019 @07:08PM (#19895189)
> a xor r32, r32 is 2 bytes, not 1

Does the article imply otherwise?

Re:F() vs. F(void) in C vs. C++ by biesnecker on Sunday May 12, 2019 @07:12PM (#19895202)
Yes.

> So Clang can potentially save you a single instruction (xorl %eax, %eax) whose encoding is only 1B, per function call to functions declared in the style f(), but only IF the definition is in the same translation unit and doesn’t differ from the declaration, and you happen to be targeting x86_64.

Re:F() vs. F(void) in C vs. C++ by saagarjha on Sunday May 12, 2019 @07:19PM (#19895246)
I couldn't seem to find that bit, thanks for pointing it out to me.
Re:F() vs. F(void) in C vs. C++ by ndesaulniers on Sunday May 12, 2019 @07:23PM (#19895266)
I just updated the article, too, sorry if that caused confusion.
Re:F() vs. F(void) in C vs. C++ by cblum on Sunday May 12, 2019 @07:12PM (#19895203)
Yes.