Created on 2012-05-27.00:00:00 last changed 148 months ago
Rationale (September, 2012):
This issue is based on the wording prior to the application of the resolution of issue 1288. With that change, there is no longer a problem.
In an example like
const int&r {1};
the expectation is that this creates a temporary of type const int containing the value 1 and binds the reference to it. And it does, but along the way it creates two temporaries. The wording in 9.4.5 [dcl.init.list] paragraph 3, the bullet on reference initialization, says that a prvalue temporary of type const int is created, and then we do reference binding. Because this is a non-class case and the source is a prvalue, we end up in the section of 9.4.4 [dcl.init.ref] that says we create a temporary (again of type const int) and initialize it from the source. So we've created two temporaries. Now, this may not matter to anyone, since the discarded temporary is not observable, but it may be a concern that the reference is not binding directly to the temporary created for the {1}, since we do sometimes base behavior on the “bind directly” attribute.
History | |||
---|---|---|---|
Date | User | Action | Args |
2012-09-24 00:00:00 | admin | set | messages: + msg4033 |
2012-05-27 00:00:00 | admin | create |