Skip to content

CWG2910 [basic.def.odr] Effect of requirement-parameter-lists on odr-usability #561

Description

@hubert-reinterpretcast

Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong

Reference (section label): basic.def.odr

Link to reflector thread (if any): N/A

Issue description:
Consider

bool f() {
  constexpr int z = 42;
  return requires {
    sizeof(int [*&z]);
  } && requires (int x) {
    sizeof(int [*&z]);
  };
}

According to https://wg21.link/basic.scope.param, a function parameter scope is produced for the second requires-expression.

This means that, under https://wg21.link/basic.def.odr#10, there is an intervening function parameter scope that prevents z from being odr-usable in the context where it is named in the second requires-expression. There does not appear to be a good reason for the two requires-expression‌s to behave differently.

Suggested resolution:
Insert in https://eel.is/c++draft/basic.def.odr#10.2.2:

  • the intervening scope is the function parameter scope of a requires-expression or a lambda-expression [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions