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
[basic.compound] p4 What the definition of whether two objects are the same CWG2606 #5356
Comments
The definition of |
The issue here is that, whether |
[expr.static.cast] p13 says:
We agree the original pointer points to the v object, of type "const int". And there is an object b of type "int" (ignoring cv-qualification), which is the same object as the v object, so the result is a pointer to that v object. In this example, there is only ever one object we're talking about, and I think it goes without definition that x is the same as x (for any x). |
How could an object of type
which means, any modification to that object is well-defined, because
Thus, any modification to |
"is exactly that b and a are not the same object" That can't be, because there is only a single object. Either "b" doesn't exist at all ("there is an object b of type T"), or it exists and then it's the same as a. |
This is the obscure point here. Informally, any object is unique, an object cannot be of both type
The requirement of the first branch is that:
Where
In short, there is an object
The key point is whether |
I don't see anything here creating a distinct |
@frederick-vs-ja The key point is whether the conversion falls into
or
you seem to admit that the conversion should fall into the second branch. Take more attention to [expr.unary.op] p1
Assume the case falls into the first branch, that branch specifies that the result is a pointer to the object |
When there is not a different b object, IIUC two branches are not distinguishable. Note the "ignoring cv-qualification".
"An lvalue referring to the object" is not needed to have the type of that object. |
The destination of this conversion is "prvalue of type pointer to int(T)" where
An lvalue certainly can have a different type as the type of the actual object to which the expression points. The correct interpretation to [expr.unary.op] p1 is stated in P1839. As I have said in the above comments, the original object
No, since |
IIUC there is, as "ignoring cv-qualification" is applied to the phrase "there is an object b of type |
I don't understand what it means. Would you prefer to directly ignore the introduction of
Isn't
What is the destination of the conversion? In this case, it is the prvalue of type pointer to cv2 int, Isn't it? So, |
No. How can I select to directly ignore the introduction of
This is what I disagree. Given
Totally agree for this. |
That is our divergence here. In other words, the ambiguity of this portion. I construe "ignore cv-qualification" for any type If it were the meaning of what you said, we should take the similar manner as [over.match.funcs.general] p7 did
Instead of saying ignore the cv-qualification. Such as [temp.param] p6
template<int const V>
void fun(){
decltype(V) i = 0; // ignore the cv-qualification
i = 1;
} Even a more similar context, see [expr.cond] p4
which means make the qualification-decomposition of
while the qualification-decomposition of
It requires that struct C{int a;};
using CvT = C const;
template<class T>
struct Identity{};
int main(){
C E;
std::cout<< typeid(Identity<decltype(true? E: CvT{})>).name(); // Identity<C const>
} |
When the standard compares 2 types and says «(ignoring cv-qualification)», in all places it means to ignore cv-qualification on both types, not only on that which is close to «(ignoring cv-qualification)». |
That means the result would point to object |
Where? |
T is the type specified in pointer to cv2 T, where the top-level cv-qualification of the pointed-to type is denoted by |
[expr.static.cast] p13 states
[basic.compound] p4.1 states
Consider this example:
The pointer value of
vptr
points tov
as per [conv.ptr] p2, the result ofconst_cast<void*>(cvptr)
refers to the original entity(the same pointer value as vptr's) as per [expr.const.cast] p3. After figuring out whatvptr
is, we can pay more attention to#3
, which is the case specified in [expr.static.cast] p13 where the conversion is that converts a prvalue of "pointer to void" to a prvalue of type "pointer to int". In this case, the original pointer value points tov
(which is objecta
, whose type isint const
) while the expected objectb
is of typeint
. They have different types. So, the issue is whether two objects that have similar types but are not the same can be the same object? From the perspective of English, when we say two objects are the same, they should be identical in any respect at least.The text was updated successfully, but these errors were encountered: