On 10 December 2015 at 16:15, John McCall <[email protected]> wrote:
> > On Dec 10, 2015, at 4:11 PM, Nelson, Clark <[email protected]> > wrote: > > > > It has come to my attention that GCC and clang generate incompatible code > > for passing an argument of an empty class type. > > > > clang seems to completely ignore arguments and parameters of empty class > > type -- which seems to make a certain amount of sense. > > > > OTOH, as far as I understand it, GCC effectively treats an empty class > > equivalently to a class containing a single member with some character > > type -- which also seems pretty reasonable. > > > > Should the C++ ABI come down on one side or the other of this question? > > > > This is really the sort of question a psABI should settle. But of course > > the C language doesn't actually support a structure with no members, so > > it's not too surprising if a psABI doesn't nail down what should happen > > for this. > > It’s valid as a C extension in GCC. If there are platforms where we use a > different rule from GCC, we should come to some understanding with them. > > Because of the GCC extension, C++ can’t really use different rules from C. (For x86_64:) GCC uses different rules for C and C++. In C, they do not pass anything. In C++, they pass a 1-byte object on the stack. Clang uses the same rules for C and C++, passing nothing in both cases. A careful reading of the x86_64 psABI suggests that clang is right in both cases; the eightbyte corresponding to the 1-byte empty struct parameter is never classified (at all), so should occupy neither a register nor memory, but it's not really especially clear. In any case, I think GCC should be the one to change here, because its C and C++ ABIs don't match.
_______________________________________________ cxx-abi-dev mailing list [email protected] http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev
