Created on 2003-09-14.00:00:00 last changed 238 months ago
Rationale (April, 2005):
As acknowledged in the description of the issue, the referenced text is only a note and has no normative impact. Furthermore, the examples cited do not involve the conversions mentioned in the note, and the normative text is already sufficiently clear that the types in the examples are not reference-compatible.
In section 9.4.4 [dcl.init.ref], paragraph 5, there is following note:
Note: the usual lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are not needed, and therefore are suppressed, when such direct bindings to lvalues are done.
I believe that this note is misleading. There should be either:
The problem:
int main() { const int ci = 10; int * pi = NULL; const int * & rpci = pi; rpci = &ci; *pi = 12; // circumvent constness of "ci" }
int main() { int * pi = NULL; const int * const & rcpci = pi; // 1 int i = 0; pi = &i; // 2 if (pi == rcpci) std::cout << "bound to lvalue" << std::endl; else std::cout << "bound to temporary rvalue" << std::endl; }
There has been discussion on this issue on comp.lang.c++.moderated month ago, see http://groups.google.pl/groups?threadm=9bed99bb.0308041153.1c79e882%40posting.google.com and there seems to be some confusion about it. I understand that note is not normative, but apparently even some compiler writers are misled (try above code snippets on few different compilers, and using different compilation options - notably GCC 3.2.3 with -Wall -pedantic), thus it should be cleared up.
My proposal is to change wording of discussed note to:
Note: result of every standard conversion is never an lvalue, and therefore all standard conversions (clause 4) are suppressed, when such direct bindings to lvalues are done.
History | |||
---|---|---|---|
Date | User | Action | Args |
2005-05-01 00:00:00 | admin | set | messages: + msg1198 |
2005-05-01 00:00:00 | admin | set | status: drafting -> nad |
2003-11-15 00:00:00 | admin | set | status: open -> drafting |
2003-09-14 00:00:00 | admin | create |