------- Additional Comments From giovannibajo at libero dot it 2004-03-17 14:37 ------- FWIW, I agree. We ran into this very problem also in PR 14528, it seems like GCC 3.4.0 is the first compiler to enforce this rule. Not even EDG does this. Standard paragraphs that apply: - [basic.lval]/6 says that "D()" is a rvalue. - [dcl.init.ref]/5, bullet 2 ("Otherwise, the reference shall be to a non- volatile const type"), sub-bullet 1: "If the initializer expression is a rvalue, the refence is bound in one of the following ways (the choice is implementation defined): - The reference is bound to the object represented by the rvalue (see 3.10) [...] — A temporary of type “cv1 T2” [sic] is created, and a constructor is called to copy the entire rvalue object into the temporary. The reference is bound to the temporary [...] ***The constructor that would be used to make the copy shall be callable whether or not the copy is actually done.***" The last sentence (with my stress) is the one that matters. Either GCC internally elides the copy or not, it does not matter, but the copy constructor has to be callable. - [class.temporary]/2 talks about this another time: "Temporaries of class type are created in various contexts: binding an rvalue to a reference, [...]. Even when the creation of the temporary object is avoided, all the semantic restrictions must be respected as if the temporary object was created. [Example: even if the copy constructor is not called, all the semantic restrictions, such as accessibility (clause 11), shall be satisfied.]". -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14618