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

            Bug ID: 57319
           Summary: [4.8/4.9] Regression: bogus "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: ppluzhnikov at google dot com

Google reference: b/9004260


Test case:

class A { };
class B: virtual A { };
class C: virtual B { };

class D: C
{
   void operator= (D &);
};


Using current trunk (@r199023):

g++ -c t.ii -std=c++11
t.ii:3:7: warning: defaulted move assignment for ‘C’ calls a non-trivial move
assignment operator for virtual base ‘B’ [-Wvirtual-move-assign]
 class C: virtual B { };
       ^

Richard Smith writes:

  The problem is that a defaulted move assignment for a class with two
  inheritance paths to a virtual base may move-assign that virtual base
  multiple times (and thus may lose state).

  However, this particular case *isn't* the problematic case, because
  (a) this sample code should not trigger the definition of C's move
      assignment operator, and
  (b) there is only one inheritance path from C to B, so it won't be
      move-assigned multiple times, and
  (c) the issue isn't with *non-trivial* move assignments, it's with
      *user-provided* move-assignments (for the virtual base or any of its
      subobjects), which B does not have.

  => This is a false positive.

Reply via email to