[Issue 3008] Members of non-lvalues (rvalues) can be assigned to.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 29 10:11:30 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3008





--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com>  2009-07-29 10:11:26 PDT ---
(In reply to comment #3)
> Actually the compiler wouldn't have to do anything special here.  If the return
> of foo() were an rvalue, then *foo().a could still be an lvalue, not because of
> any special rules, but because of how the dereference operator works.

Yes, that would be helpful.

I think you are right that it can be determined in simple cases, but for sure
there will be cases that the compiler cannot diagnose, such as:

int _global;

struct S
{
  int _x;
  version(noop)
    void x(int n) { _x = n;}
  else
    void x(int n) { _global = n;}
}

struct S2
{
  S foo() { return S(5);}
}

void main()
{
  S2 s2;
  s2.foo.x = 5;
}

How does the compiler know when compiling with noop that the s2.foo.x = 5
doesn't do anything?  Especially if the module containing main is using a di
file to define S and S2.

The result is, I don't think the compiler can diganose the complex cases, and
most of the time, the cases are complex.

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


More information about the Digitalmars-d-bugs mailing list