http://d.puremagic.com/issues/show_bug.cgi?id=3378
Steven Schveighoffer <schvei...@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schvei...@yahoo.com --- Comment #7 from Steven Schveighoffer <schvei...@yahoo.com> 2010-03-04 04:33:04 PST --- testing: [ste...@steveslaptop ~]$ cat testit.c int x; int * foo() { return &(++x); } [ste...@steveslaptop ~]$ gcc -c testit.c testit.c: In function ‘foo’: testit.c:4: error: lvalue required as unary ‘&’ operand [ste...@steveslaptop ~]$ g++ -c testit.c [ste...@steveslaptop ~]$ So, C (at least in gcc) does not consider ++x an lvalue, C++ (g++) does. This is consistent with what Walter says. Choosing one or the other is arbitrarily right or wrong depending on what compatibility you wish to have. I agree that defining ++x to be equivalent x+=1 for all types of x is bad, but defining it that way for builtins is fine. I don't see a huge benefit to having ++x return an lvalue. Why can't you rewrite bump like so? ref int bump(ref int x) { ++x; return x;} This should work for all types of x. In practice, I don't think using ++x as an lvalue comes up much. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------