News for hackers. Stuff that matters.
Re:C++ Patterns: The Badge by vnorilo on Wednesday June 12, 2019 @01:32AM (#20162019)
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-

Re:C++ Patterns: The Badge by xleviator on Wednesday June 12, 2019 @03:27AM (#20162492)
Sure within a single compilation unit. Otherwise, I like dearrifling's suggestion.
Re:C++ Patterns: The Badge by vnorilo on Wednesday June 12, 2019 @03:40AM (#20162543)
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.

Re:C++ Patterns: The Badge by xleviator on Wednesday June 12, 2019 @10:45AM (#20165163)
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.
Re:C++ Patterns: The Badge by vnorilo on Wednesday June 12, 2019 @11:12AM (#20165406)
thanks for clarification! you’re of course right about the calling convention.