Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is no performance penalty in any modern compiler that I am aware of (effectively no code will be emitted).

You can have a look here: https://godbolt.org/z/DmeYL-




Sure within a single compilation unit. Otherwise, I like dearrifling's suggestion.


The example also shows a call to a different translation unit. There's no code for passing the empty struct. There's also none for handling it, as you can see from the assembly output.

The one byte rule does nothing here, because its value is undefined and its address not observable.

edit: if you find a case where an empty struct parameter causes code to be emitted, let's consider filing bugs.


Oops, I did miss that, but this seems to be compiler or calling convention specific. x86_64 gcc 9.1, linked, shows no difference. However arm64 gcc 8.2 and x86-64 clang show a difference.


thanks for clarification! you’re of course right about the calling convention.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: