[cxx-abi-dev] The magic of uncalled copy constructors; documenting the bug

Richard Smith richardsmith at google.com
Mon Feb 10 02:17:34 UTC 2014


On 9 February 2014 05:37, Hubert Tong <hstong at ca.ibm.com> wrote:

> Core Issue 1590 mentions that the trivial copy or move constructor should
> be non-deleted and accessible.
> Replacing the pair of copy constructors below with private, deleted copy
> and move constructors seems to make GCC avoid the "magic" copy, but not
> Clang.
> Which compiler has the preferred behaviour?
>
I think GCC does, whereas Clang obeys the current description of the ABI.

Under the current wording of core issue 1590, we're not allowed to perform
a 'trivial' copy here. I think we should update the ABI document (in
3.1.1/1) to make this work (perhaps something equivalent to replacing
"non-trivial" with "non-trivial, non-public, or deleted" each time it
occurs).

> Thanks,
>
>
> Hubert Tong
>
> Richard Smith <richardsmith at google.com> wrote on 08-02-2014 05:39:21 PM:
>
> > From: Richard Smith <richardsmith at google.com>
> > To: Hubert Tong/Toronto/IBM at IBMCA,
> > Cc: "cxx-abi-dev at codesourcery.com" <cxx-abi-dev at codesourcery.com>
> > Date: 08-02-2014 05:39 PM
> > Subject: Re: [cxx-abi-dev] The magic of uncalled copy constructors;
> > documenting the bug
>
> >
> > On 8 February 2014 12:43, Hubert Tong <hstong at ca.ibm.com> wrote:
> > 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.
> > Agreement here and (IIRC) in CWG was that this is a defect in the
> > language spec, not in the ABI. See core issue 1590.
> > 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);
> > }
> >
> > _______________________________________________
> > cxx-abi-dev mailing list
> > cxx-abi-dev at codesourcery.com
> > http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20140209/c6685b74/attachment.html>


More information about the cxx-abi-dev mailing list