U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ Developers corner » Should the pick semantics be changed?
Re: Should the pick semantics be changed? [message #42362 is a reply to message #42329] Sun, 09 March 2014 09:34 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
piotr5 wrote on Fri, 07 March 2014 10:23

I agree, imho this is a bug in gcc (or maybe also in c++11 standard): every return statement should pass the arguments as rvalue to the return-type constructor since the return statement is leaving scope and thereby its parameters have the same properties as all implicite rvalue objects: unlikely to remain (unless static), should not be altered except for purposes of picking, definitely a temporary value.



thinking about it, consider

struct Foo {
   Vector<int> bar;
 
   Vector<int> Bar() { return bar; }
};


Now perhaps compiler could distinguish the situation where local lvalue is returned, but I guess rules would become complicated here....

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: D lang support
Next Topic: [Compilation] Include .asm files in build
Goto Forum:
  


Current Time: Tue May 19 09:31:30 GMT+2 2026

Total time taken to generate the page: 0.00797 seconds