[cxx-abi-dev] Volatile nonstatic data members

David Vandevoorde daveed at edg.com
Fri Mar 6 17:35:46 UTC 2015


At some point, the C++ standard changed to cause volatile nonstatic data members to make a generated copy/move constructor nontrivial.

Unfortunately, that would change the parameter passing mechanism if we stuck to letter of the ABI; see 3.1.1/1:

1. In the special case where the parameter type has a non-trivial copy constructor or destructor, the caller must allocate space
   for a temporary copy, and pass the resulting copy by reference (below). Specifically, ...

AFAICT, recent versions of GCC and Clang do implement the language aspects of nontriviality of copy/move constructors in such cases (e.g., causing union constructors to become deleted), but not this ABI aspect of it.  For example:

 typedef struct { int value; } TypeA;
 typedef struct { TypeA volatile value; } TypeB;
 typedef struct { TypeA value; } TypeC;

 int foo(TypeB p) { return p.value.value; }
 int foo(TypeC p) { return p.value.value; }

Identical code is being generated for these two definitions of foo, even though TypeB has a nontrivial copy constructor and TypeC has a trivial copy constructor.

If that is right, should the 3.1.1/1 words above be edited to read:

1. In the special case where the parameter type has a non-trivial copy constructor (with the exception of a generated copy constructor that is
   nontrivial only because one or more nonstatic data member are trivial) or destructor, the caller must allocate space for a temporary copy,
   and pass the resulting copy by reference (below).  Specifically, ...

?

	Daveed

P.S.: I sent this e-mail from a different account a few days ago.  Sorry if anyone sees it twice.



More information about the cxx-abi-dev mailing list