Skip to content

[diff.expr] Paragraph added by CWG2875 is not correct for C23 #9248

Description

@Halalaluyafail3

[diff.expr]/5 contains the following example:

void f() {
  char *p = nullptr;
  char *p2 = &*p;       // well-defined in C, undefined behavior in C++
  char *p3 = &p[0];     // well-defined in C, undefined behavior in C++
  int a[5];
  int *q = &a[5];       // well-defined in C, undefined behavior in C++
}

In C &p[0] gets translated to p+0 which is undefined in C23, though it is valid in C2Y because of N3322. Should the second comment be updated since C++ currently references C23?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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