[cxx-abi-dev] The magic of uncalled copy constructors; documenting the bug
Hubert Tong
hstong at ca.ibm.com
Sat Feb 8 20:43:06 UTC 2014
Hi all,
I think this has been visited every once in a while with regards to the
addition of move constructors, defaulted and deleted constructors, etc.
The following case magically works thanks to a pair of copy constructors
which are never used by the program, and breaks otherwise because of an
issue with the calling conventions.
As a consumer of the ABI document, I would appreciate if it mentioned the
known cases where it is not suitable for a compliant implementation of the
C++ language.
Thanks,
Hubert Tong
#include <cassert>
class A {
private:
#if ! REMOVE_COPY_CTOR
A(const A &, void * = 0);
A(const A &, bool = 0);
#endif
public:
template <typename T>
A(const volatile T &t) : a(t.a), b(a) { }
A() : a(0), b(a) { }
long a, &b;
};
long bar(A a) {
++a.b;
return a.a;
}
int main() {
volatile A a;
long ret = bar(a);
assert(ret == 1);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20140208/004009cb/attachment.html>
More information about the cxx-abi-dev
mailing list