[Issue 3167] Passing result of a function call as ref argument no longer works

2014-04-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3167

Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

Version|1.046   |D1

--


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-02-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167



--- Comment #16 from Don clugd...@yahoo.com.au 2010-02-07 07:21:15 PST ---
(In reply to comment #15)
 (In reply to comment #13)
  It is invalid code because you are taking a reference to the return value 
  of a
  function. Functions return, by definition, rvalues. You cannot take a 
  reference
  to an rvalue.
 
 But it used to work before.

It didn't. It only seemed to work. In simple cases it happened to work, in more
difficult cases it failed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


--- Comment #10 from Walter Bright bugzi...@digitalmars.com 2010-01-29 
11:55:29 PST ---
I'm going to mark this as invalid, as function return values should be rvalues,
and rvalues cannot be references, even if the vagaries of the implementation
make that possible.

The reason is vagaries of the implementation, so it may work on one
implementation but not another. Currently, whether it (used to) work or not
also depended on the contents of the struct being returned.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Andrei Alexandrescu and...@metalanguage.com changed:

   What|Removed |Added

 CC||and...@metalanguage.com


--- Comment #11 from Andrei Alexandrescu and...@metalanguage.com 2010-01-29 
12:27:07 PST ---
(In reply to comment #10)
 I'm going to mark this as invalid, as function return values should be 
 rvalues,
 and rvalues cannot be references, even if the vagaries of the implementation
 make that possible.
 
 The reason is vagaries of the implementation, so it may work on one
 implementation but not another. Currently, whether it (used to) work or not
 also depended on the contents of the struct being returned.

Why should we leave this to vagaries? An rvalue is not an lvalue, period.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Eldar Insafutdinov e.insafutdi...@gmail.com changed:

   What|Removed |Added

 CC||e.insafutdi...@gmail.com


--- Comment #12 from Eldar Insafutdinov e.insafutdi...@gmail.com 2010-01-29 
15:00:25 PST ---
(In reply to comment #10)
 I'm going to mark this as invalid, as function return values should be 
 rvalues,
 and rvalues cannot be references, even if the vagaries of the implementation
 make that possible.
 
 The reason is vagaries of the implementation, so it may work on one
 implementation but not another. Currently, whether it (used to) work or not
 also depended on the contents of the struct being returned.

This test case fails for me with the latest dmd:

struct X {
}

X i() {
return X.init;
}

void foo(const ref X x) {
}

void foo() {
foo(i()); //line 12
}

This bug is not invalid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167



--- Comment #13 from Walter Bright bugzi...@digitalmars.com 2010-01-29 
15:50:10 PST ---
It is invalid code because you are taking a reference to the return value of a
function. Functions return, by definition, rvalues. You cannot take a reference
to an rvalue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2010-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Steven Schveighoffer schvei...@yahoo.com changed:

   What|Removed |Added

 CC||schvei...@yahoo.com


--- Comment #14 from Steven Schveighoffer schvei...@yahoo.com 2010-01-29 
19:24:11 PST ---
(In reply to comment #13)
 It is invalid code because you are taking a reference to the return value of a
 function. Functions return, by definition, rvalues. You cannot take a 
 reference
 to an rvalue.

This breaks custom types.  Who are you as the compiler to assume my type is an
rvalue?

e.g.

class MyClass
{
   struct myForwardRange {...}
   @property myForwardRange all() {...}   
}

void copy(R1, R2)(ref R1 inputrange, ref R2 outputrange)
{
...
}

void foo(MyClass mc, OutputRange r)
{
   copy(mc.all, r);
}

Another case:

struct LargeStruct
{
  int[100] bigarray;
  void print(streamtype s) {s.print(bigarray);}
}

class X
{
  LargeStruct createalargestruct() {...}
}

void foo(X x)
{
  x.createalargestruct().print(stdout);
}

Also, if you can't call properties on a struct, which essentially needs a
reference to the struct, then you can't get any properties from a returned
struct.

This rule is way too limiting.  at the very least, const rvalue references need
to be allowed for any reasonable value types that are not just POD to be
created.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2009-10-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 CC||2kor...@gmail.com


--- Comment #9 from Don clugd...@yahoo.com.au 2009-10-15 05:27:05 PDT ---
*** Issue 2852 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2009-08-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au




--- Comment #4 from Don clugd...@yahoo.com.au  2009-08-06 00:08:01 PDT ---
(In reply to comment #3)
 I'm fairly sure this was by design (bug 2621) in D 2.026, but I don't think it
 was expected to seep through to D1.

It might be related to the fix for bug #2323 ? My patch for that bug was
rejected, so I don't know what changes were made.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2009-08-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Bill Baxter wbax...@gmail.com changed:

   What|Removed |Added

 CC||wbax...@gmail.com




--- Comment #5 from Bill Baxter wbax...@gmail.com  2009-08-06 06:40:55 PDT ---
(In reply to comment #3)
 I'm fairly sure this was by design (bug 2621) in D 2.026, but I don't think it
 was expected to seep through to D1.

I hope you're right.  
In D2 you can have the ref argument be const (which I hope eliminates the
error), but in D1 you have no such option.  So you often have to resort to
making arguments 'ref' for efficiency even when the function doesn't modify the
argument.

Also the error message could be a little clearer.  Something like Can't pass a
temporary to a function taking a ref argument would be a lot clearer I think. 
Passing something to a function taking a ref does not necessarily imply
assigning to that ref argument in D1, for the reason stated above.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2009-08-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167





--- Comment #6 from Don clugd...@yahoo.com.au  2009-08-06 12:24:14 PDT ---
This change is clearly caused by the addition of the new function

Expression *CallExp::modifiableLvalue(Scope *sc, Expression *e)

in expression.c. Comment it out to restore the old behaviour. It doesn't seem
to be necessary for any bug fixes -- eg, removing it doesn't reactivate bug
2323.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3167] Passing result of a function call as ref argument no longer works

2009-07-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3167


Christian Kamm kamm-removet...@incasoftware.de changed:

   What|Removed |Added

 CC||kamm-removet...@incasoftwar
   ||e.de




--- Comment #3 from Christian Kamm kamm-removet...@incasoftware.de  
2009-07-12 12:35:26 PDT ---
I'm fairly sure this was by design (bug 2621) in D 2.026, but I don't think it
was expected to seep through to D1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---