Skip to content

[diff.expr] Strike line in example that is UB in C23 - #9249

Open
jensmaurer wants to merge 1 commit into
cplusplus:mainfrom
jensmaurer:c73
Open

[diff.expr] Strike line in example that is UB in C23#9249
jensmaurer wants to merge 1 commit into
cplusplus:mainfrom
jensmaurer:c73

Conversation

@jensmaurer

Copy link
Copy Markdown
Member

In C23, "p + 0" is undefined behavior if p is a nullptr, regardless of whether the result is dereferenced.

Fixes #9248

In C23, "p + 0" is undefined behavior if p is a nullptr,
regardless of whether the result is dereferenced.
@jensmaurer

Copy link
Copy Markdown
Member Author

The two other lines in the example are sufficient exposition for the C incompatibility we wish to highlight.

@jensmaurer
jensmaurer requested a review from eisenwave September 7, 2026 21:07

@eisenwave eisenwave left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. Keeping the deleted line would be somewhat misleading because the UB happens earlier, so that line isn't really demonstrating what the example is meant to be about.

One might ponder whether it makes sense to keep the line for C2y (since adding 0 to null would be fine), but I don't think this line is crucial for that purpose either.

@jensmaurer

Copy link
Copy Markdown
Member Author

@tkoeppe , you're next.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants