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?

Thanks,


Hubert Tong

Richard Smith <[email protected]> wrote on 08-02-2014 05:39:21 PM:

> From: Richard Smith <[email protected]>
> To: Hubert Tong/Toronto/IBM@IBMCA,
> Cc: "[email protected]" <[email protected]>
> 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 <[email protected]> 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
> [email protected]
> http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev
_______________________________________________
cxx-abi-dev mailing list
[email protected]
http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev

Reply via email to