cplusplus / cplusplus/draft

Is a null pointer value of a pointer type be called a pointer?

Open
#4,662 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

Please see this example

 (void*)0 == (char*)0;

The operands of the equal operator are a null pointer value of type void* and a null pointer value of type char*, respectively as per:

A null pointer constant is an integer literal ([lex.icon]) with value zero or a prvalue of type std​::​nullptr_­t. A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type ([basic.compound]) and is distinguishable from every other value of object pointer or function pointer type.

Meanwhile, [expr.eq#3] states that

If at least one of the operands is a pointer, pointer conversions, function pointer conversions, and qualification conversions are performed on both operands to bring them to their composite pointer type. Comparing pointers is defined as follows:

The two operands after conversion should both be pointers if one of them is original a pointer. However, according to the relevant rule in [basic.compound]#3

Except for pointers to static members, text referring to “pointers” does not apply to pointers to members. Pointers to incomplete types are allowed although there are restrictions on what can be done with them ([basic.align]). Every value of pointer type is one of the following:

  • a pointer to an object or function (the pointer is said to point to the object or function), or
  • a pointer past the end of an object ([expr.add]), or
  • the null pointer value for that type, or
  • an invalid pointer value.

Except for the first two bullets, they are explicitly called pointer; the remaining cases are not explicitly called pointer. In other words, Can a null pointer value or invalid pointer value be called a pointer? It seems that there is no rule elsewhere in the standard that states any value of pointer type is called a pointer. If it is say, the two operands of the equal operator should be invalid in this example.

Anyway, the issue here is that, Is an arbitrary value of pointer type called pointer?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cited [expr.eq#3] and [basic.compound]#3 clauses, then review the six-comment discussion for the terminology question. Determine whether the draft needs a wording clarification about values of pointer type, and consider the work complete when the terminology is resolved and an agreed standard-draft change is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.