https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68754

            Bug ID: 68754
           Summary: Explicitly defaulted constexpr assignment operator
                    fails to compile
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com
  Target Milestone: ---

The following code fails to compile on GCC 5.3.0:

    struct base { };
    struct derived : base {
        constexpr derived& operator=(derived const&) = default;
    };

The error message is

    [...]: error: explicitly defaulted function 
        'constexpr derived& derived::operator=(const derived&)' cannot 
        be declared as constexpr because the implicit declaration is 
        not constexpr:
         constexpr derived& operator=(derived const&) = default;
                            ^
    [...]: note: defaulted constructor calls non-constexpr 
        'base& base::operator=(const base&)'
     struct base { };
            ^
    [...]: note: 'base& base::operator=(const base&)' is not usable as a 
        constexpr function because:


However, the default-generated assignment operator of `base` is constexpr.
Live example: http://melpon.org/wandbox/permlink/GUJHQDuVaWOkwObj

Reply via email to