-
Notifications
You must be signed in to change notification settings - Fork 771
Is a null pointer value of a pointer type be called a pointer? #4662
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
Comments
[expr.eq] p2 says "The converted operands shall have arithmetic, enumeration, pointer, or pointer-to-member type" so it seems obvious to me that when p3 says an operand "is a pointer" it means it has pointer type. The obvious answer to your question is yes, everything that has pointer type is a pointer. I think you are reading too much into the list in [basic.align]. I read it as "a pointer to something, or a pointer past the end of something, or ..." not as a definition of what is and isn't "a pointer". |
Yes, you clearly explain the meaning of what is a pointer but it's not clear by the normative rule.
Could we highlight the concept by using the normative rule? The meaning(everything that has pointer type is a pointer) seems not clear in the standard. After all, all concepts about pointer are introduced by [basic.compound]. In order to make the meaning more readable, I think [basic.compound#3] might be changed to
That could indicate what you say "everything that has pointer type is a pointer.", and they can be subsumed to four kinds of pointers listed in the rule. |
No. We need to clearly differentiate between "pointer type" and "a value of pointer type". The list in [basic.compound] p3 addresses the latter question (and uses proper terminology to do that). Instead, the ancient text in [expr.eq] should be changed to talk about "operands of pointer type" and then say "Comparing values of pointer type is defined as follows". The term "pointer" should not be used in the (core) portion of the standard. |
That's totally what I originally thought before issuing this question. But I also think we should clarify what can be called pointer by using a normative rule, after all, the wording "pointer" is referred to in many sections in the standard. |
"But I also think we should clarify what can be called pointer by using a normative rule" No, we need to inspect the instances of "pointer" use one-by-one and fix them one way or the other. For example, the section you quoted in [expr.eq] uses "pointer" for both "pointer type" and "value of pointer type". Not good, and not fixable by defining "pointer". |
Oh, I see it. You mean we should eliminate the wording " pointer" appeared in the normative rule in some sections, and replace it with its concrete meaning defined in [ basic. compound] according to the context. It sounds greate. |
Please see this example
The operands of the equal operator are a null pointer value of type
void*
and a null pointer value of typechar*
, respectively as per:Meanwhile, [expr.eq#3] states that
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 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?The text was updated successfully, but these errors were encountered: