http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59312

            Bug ID: 59312
           Summary: Incorrect warning "defaulted move assignment for ...
                    calls a non-trivial move assignment operator for
                    virtual base ..."
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexander.o.khovansky at yandex dot com

Minimal test case:

#include <string>
struct A { std::string s; };
struct B : virtual A {};

int main(int argc, char* argv[]) {
    B b1, b2;
    b2 = b1;
}

This produces warning at line 3:
defaulted move assignment for ‘B’ calls a non-trivial move assignment operator
for virtual base ‘A’ [-Wvirtual-move-assign]

Tested on versions available on gcc.godbolt.org - 4.8.1, 4.9.0 20130909 - with
option -std=c++11.


The standard says the following.

12.8.20:
If the definition of a class X does not explicitly declare a move assignment
operator, one will be implicitly declared as defaulted if and only if
...
— the move assignment operator would not be implicitly defined as deleted.

12.8.23:
A defaulted ... move assignment operator for class X is defined as deleted if X
has:
...
— any direct or indirect virtual base class.

The B class does have virtual base, so it cannot have implicit move assignment
operator.

Reply via email to