Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5240,7 +5240,7 @@
the \defnx{null pointer value}{value!null pointer} for that type, or
\item
\indextext{invalid pointer value|see{value, invalid pointer}}
an \defnx{invalid pointer value}{value!invalid pointer}.
an \defnx{invalid pointer value}{value!invalid pointer}\iref{basic.stc.general}.
\end{itemize}
A value of a
pointer type
Expand Down
2 changes: 1 addition & 1 deletion source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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

@blackteahamburger blackteahamburger Mar 19, 2023

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?

\impldef{lvalue-to-rvalue conversion of an invalid pointer value}.

\item Otherwise, the object indicated by the glvalue is read\iref{defns.access},
Expand Down