cplusplus / cplusplus/draft

[dcl.fct.def.default] Restrictions on what comparison operator function can be explicitly defaulted CWG2547

Open
#5,337 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[dcl.fct.def.default] p1 just states:

A function that is explicitly defaulted shall

  • be a special member function or a comparison operator function ([over.binary]), and
  • not have default arguments.

If I don't omit some other rules, there are no more restrictions on what the comparison operator function shall satisfy.

Consider this example:

enum E{};
bool operator==(E,E) = default;

This example directly causes GCC to crash while Clang reports some diagnoses for which I cannot find the corresponding wording in the standard.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [dcl.fct.def.default] p1 and its reference to [over.binary], then examine the enum comparison example and the linked Compiler Explorer behavior in GCC and Clang. Determine what restrictions explicitly defaulted comparison operator functions should satisfy and what wording is needed to define the expected diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.