Skip to content

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

Closed
cplusplus/draft
#7458

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 [...]

Activity

  1. changed the title [-][basic.def.odr] Effect of requirement-parameter-lists on lambda-captures[/-] [+][basic.def.odr] Effect of requirement-parameter-lists on odr-usability[/+] on Jun 24, 2024
  2. jensmaurer commented on Jun 26, 2024

    @jensmaurer
    Member
  3. changed the title [-][basic.def.odr] Effect of requirement-parameter-lists on odr-usability[/-] [+]CWG2910 [basic.def.odr] Effect of requirement-parameter-lists on odr-usability[/+] on Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions