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

[conv.lval] Fix cross-reference for 'invalid pointer value' #5886

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

blackteahamburger
Copy link
Contributor

The definition of 'invalid pointer value' is in [basic.compound] rather than [basic.stc.dynamic.deallocation].

@JohelEGP
Copy link
Contributor

JohelEGP commented Oct 4, 2022

With a git reset --hard HEAD~ and git push -f remote you wouldn't have needed to close #5883.

@blackteahamburger
Copy link
Contributor Author

With a git reset --hard HEAD~ and git push -f remote you wouldn't have needed to close #5883.

Thanks.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2022

The definition of 'invalid pointer value' is in [basic.compound] rather than [basic.stc.dynamic.deallocation].

Could you please point out where that definition is exactly?

@JohelEGP
Copy link
Contributor

JohelEGP commented Nov 8, 2022

It's https://eel.is/c++draft/basic.compound#3.4 by exhaustion.

@JohelEGP
Copy link
Contributor

JohelEGP commented Nov 8, 2022

For instance, https://eel.is/c++draft/basic.stc.general#4 refers to the correct place.
1667868588

Perhaps it'd be better to use a \label.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2022

Right, so isn't basic.stc.general the actual point of definition, not basic.compound?

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2022

A label would be nice, too.

@JohelEGP
Copy link
Contributor

JohelEGP commented Nov 8, 2022

Right, so isn't basic.stc.general the actual point of definition, not basic.compound?

I'm not sure. But at the very least, just like how https://eel.is/c++draft/basic.compound#3.2 refers to where it's specified how to form a pointer past the end of an object, p3.4 could refer to [basic.stc.general].

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2022

Yes, could you make that change then?

@JohelEGP
Copy link
Contributor

JohelEGP commented Nov 8, 2022

As a separate PR? I'm not the author of this one.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2022

Sorry, no, I should have directed that to the PR author! @blackteahamburger ^^^

@blackteahamburger blackteahamburger deleted the main-fix branch March 11, 2023 10:36
@blackteahamburger blackteahamburger restored the main-fix branch March 11, 2023 10:37
@blackteahamburger blackteahamburger deleted the main-fix branch March 11, 2023 10:39
@blackteahamburger blackteahamburger restored the main-fix branch March 11, 2023 12:18
@blackteahamburger
Copy link
Contributor Author

Right, so isn't basic.stc.general the actual point of definition, not basic.compound?

I'm not sure. But at the very least, just like how https://eel.is/c++draft/basic.compound#3.2 refers to where it's specified how to form a pointer past the end of an object, p3.4 could refer to [basic.stc.general].

Done.

@@ -666,7 +666,7 @@
the glvalue.

\item Otherwise, if the object to which the glvalue refers contains an invalid
pointer value\iref{basic.stc.dynamic.deallocation}, the behavior is
pointer value\iref{basic.compound}, the behavior is
Copy link
Contributor

Choose a reason for hiding this comment

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

What about here, shouldn't this also refer to basic.stc.general for the definition of "invalid pointer"? Why is basic.compound a good reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about here, shouldn't this also refer to basic.stc.general for the definition of "invalid pointer"? Why is basic.compound a good reference?

But [basic.stc.general]/4 specifies how to form an invalid pointer value, while [basic.compound]/3.4 is the definition (so [basic.stc.general]/4 refers to [basic.compound]/3.4).

And I think

Indirection through an invalid pointer value and passing an invalid pointer value to a deallocation function have undefined behavior. Any other use of an invalid pointer value has implementation-defined behavior.

in [basic.stc.general]/4 should be better placed in [basic.compound]/3. But [basic.compound]/3 may need to be split because it is too long.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, could you explain a bit how basic.general is the definition? I don't see "invalid" mentioned in basic.general except for in that list in p3 (which doesn't seem like a definition?) and in notes.

Copy link
Member

Choose a reason for hiding this comment

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

[basic.compound] p3 contains the taxonomy of pointer values. It states "there exists a pointer value that is an invalid pointer value".

[basic.stc.general] p4 tells us about one way how to obtain an invalid pointer value (maybe there are others). It also explains a bit of the semantics of an invalid pointer value, but this should probably be moved elsewhere in the long run. For example, [conv.lval] p3.3 tells us a little more about an invalid pointer value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, right. In fact, [conv.lval] is the very subject of this PR. I'm not sure where the definition of invald value could be moved to improve the presentation; isn't basic.stc.general a good place? We could just add a cross reference to it from [basic.compound]/(3.4).

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but that's converted to use "operator*" (expr.ref p2 and expr.mptr.oper p3).

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the last two sentences of [basic.stc.general]p4 should become a note?

Except that we seem to lack normative statements elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the normative wording would have to move somewhere more appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

CWG2822 moves the normative wording "somewhere else", for unrelated reasons.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we wait for that to land then?

@tkoeppe tkoeppe added the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 8, 2023
@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2023

I think we can derive some useful cleanup opportunities here, so let's keep this open and look at it again some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision-required A decision of the editorial group (or the Project Editor) is required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants