Skip to content

CWG3007 Access check for synthesized comparison operators #2239

Open
@jensmaurer

Description

@jensmaurer

Consider:

 struct Base {
   protected:
     bool operator==(const Base& other) const = default;
   };

   struct Child : Base {
     int i;
     bool operator==(const Child& other) const = default;
   };

   bool b = Child() == Child(); // error: deleted operator== because Base::operator== is inaccessible

CWG asks EWG to determine whether the access check for Base::operator== in the protected base class should succeed when synthesizing Child::operator==. In the status quo, the access check fails because the relevant object expression is actually of type Base.

See CWG3007 for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++26Targeted at C++26CWGCore

    Type

    No type

    Projects

    Status

    Ready for review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions