Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frederick-vs-ja opened this issue Jun 4, 2022 · 4 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Jun 4, 2022

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]?

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 6, 2022

@jensmaurer jensmaurer changed the title [diff.expr] Unmentioned incompatibility with C about pointer indirection [diff.expr] Unmentioned incompatibility with C about pointer indirection CWG232 Jun 6, 2022
@jensmaurer jensmaurer added cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. labels Jun 6, 2022
@frederick-vs-ja
Copy link
Contributor Author

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
Copy link
Contributor Author

Reopening as CWG232 is closed as NAD.

Perhaps such incompatibility is intended.

@frederick-vs-ja frederick-vs-ja changed the title [diff.expr] Unmentioned incompatibility with C about pointer indirection CWG232 [diff.expr] Unmentioned incompatibility with C about pointer indirection CWG2875 Mar 20, 2024
@frederick-vs-ja
Copy link
Contributor Author

Addressed by CWG2875.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

3 participants