Skip to content

[diff.expr] Unmentioned incompatibility with C about pointer indirection CWG2875 #5506

Open
@frederick-vs-ja

Description

@frederick-vs-ja
Contributor

These usages of pointer indirection are explicitly allowed in C via WG14 N721, but seemly not allowed in C++.

int* p = &(*((int*)0)); // undefined behavior in C++, well-defined in C (DR076/N721)
int a[10];
int* q = &a[10];        // undefined behavior in C++, well-defined in C (DR076/N721)

Should we mention them in [diff.expr]?

Activity

changed the title [-][diff.expr] Unmentioned incompatibility with C about pointer indirection[/-] [+][diff.expr] Unmentioned incompatibility with C about pointer indirection CWG232[/+] on Jun 6, 2022
added
cwgIssue must be reviewed by CWG.
not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.
on Jun 6, 2022
frederick-vs-ja

frederick-vs-ja commented on Jun 6, 2022

@frederick-vs-ja
ContributorAuthor

This is CWG232. A good question located at https://stackoverflow.com/questions/47227977/is-dereferencing-invalid-pointers-legal-if-no-lvalue-to-rvalue-conversion-occurs/47229011#47229011

Thank you!


I find that this change is essentially a DR in C (DR076). And the proposed resolution of CWG232 is significantly more permissive than that of C.

frederick-vs-ja

frederick-vs-ja commented on Nov 10, 2023

@frederick-vs-ja
ContributorAuthor

Reopening as CWG232 is closed as NAD.

Perhaps such incompatibility is intended.

changed the title [-][diff.expr] Unmentioned incompatibility with C about pointer indirection CWG232[/-] [+][diff.expr] Unmentioned incompatibility with C about pointer indirection CWG2875[/+] on Mar 20, 2024
frederick-vs-ja

frederick-vs-ja commented on Mar 20, 2024

@frederick-vs-ja
ContributorAuthor

Addressed by CWG2875.

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

    cwgIssue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xmh0511@frederick-vs-ja@jensmaurer

        Issue actions

          [diff.expr] Unmentioned incompatibility with C about pointer indirection CWG2875 · Issue #5506 · cplusplus/draft