On Fri, 7 Sep 2018 at 08:06, David Brown wrote: > > In C++ programming, it is sometimes helpful to have empty structs acting > as tags. An example is "struct nothrow_t {}". > > When parameters of these types - such as "nothrow", are passed to > functions the compiler passes them as a value 0. Since the type cannot > hold any kind of value, surely it could be passed without any value at > all being placed in the corresponding parameter register or stack slot? > Or do the rules of C++ require a value here?
The ABI dictates it, and in GCC 8 it was fixed, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60336 > Going one step further, if a function takes empty tag parameters such as: > > foo(tag1_t, tag2_t, int x); > > the first two parameters take up valuable register (or stack) slots for > no useful information. Could this function be mangled to be, in effect: > > foo__tag1_t__tag2_t(int x); No, the ABI also dictates how to mangle functions.