Created on 2004-01-16.00:00:00 last changed 196 months ago
[Voted into WP at October 2005 meeting.]
Proposed resolution (October, 2004):
Insert a new bullet in 9.4.4 [dcl.init.ref] bullet 5.2 before sub-bullet 2 (which begins, “Otherwise, a temporary of type ‘cv1 T1’ is created...”):
If the initializer expression is an rvalue, with T2 an array type, and “cv1 T1” is reference-compatible with “cv2 T2”, the reference is bound to the object represented by the rvalue (see 7.2.1 [basic.lval]).
Change 7.2.1 [basic.lval] paragraph 2 as follows:
An lvalue refers to an object or function. Some rvalue expressions — those of (possibly cv-qualified) class or array typeor cv-qualified class type— also refer to objects.
Notes from the March 2004 meeting:
g++ and EDG give an error. Microsoft (8.0 beta) and Sun accept the example. Our preference is to allow the direct binding (no copy). See the similar issue with class rvalues in issue 391.
It's unclear whether the following is valid:
const int N = 10; const int M = 20; typedef int T; void f(T const (&x)[N][M]){} struct X { int i[10][20]; }; X g(); int main() { f(g().i); }
When you run this through 9.4.4 [dcl.init.ref], you sort of end up falling off the end of the standard's description of reference binding. The standard says in the final bullet of paragraph 5 that an array temporary should be created and copy-initialized from the rvalue array, which seems implausible.
I'm not sure what the right answer is. I think I'd be happy with allowing the binding in this case. We would have to introduce a special case like the one for class rvalues.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2006-04-22 00:00:00 | admin | set | status: dr -> wp |
2005-10-22 00:00:00 | admin | set | messages: + msg1281 |
2005-10-22 00:00:00 | admin | set | status: ready -> dr |
2005-05-01 00:00:00 | admin | set | status: review -> ready |
2004-11-07 00:00:00 | admin | set | messages: + msg1060 |
2004-11-07 00:00:00 | admin | set | status: drafting -> review |
2004-04-09 00:00:00 | admin | set | messages: + msg979 |
2004-04-09 00:00:00 | admin | set | status: open -> drafting |
2004-01-16 00:00:00 | admin | create |