This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/71243] New: Implicitly defined assignment operator is not constexpr even though it should be


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

            Bug ID: 71243
           Summary: Implicitly defined assignment operator is not
                    constexpr even though it should be
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michele.caini at gmail dot com
  Target Milestone: ---

Explicitly defaulted constexpr assignment operator fails to compile.
See the minimal, failing example below:

    struct S {
        constexpr S& operator=(const S &) = default;
    };

    int main() { }

Tested on debian (Testing), g++ v5.3.1-19.
The same applies to g++ v5.3.0, while it works with g++ v6.1.0 (tested on
godbolt.org).

The error is:

    2 : error: explicitly defaulted function 'constexpr S& S::operator=(const
S&)' cannot be declared as constexpr because the implicit declaration is not
constexpr:
    constexpr S& operator=(const S &) = default;
    ^
    Compilation failed

According to 12.8p26, it should compile for the one implicitly defined ought to
be constexpr too.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]