Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Is (++i)++ legal?
Okay, I know that this is a stupid question, but I am curious: Should the following be legal? #include <iostream> using namespace std; int main() { int i = 0; (++i)++; // <-- the question is about this cout << i << endl; return 0; } It does compile with gcc but not with dmc 8.49. I thought that (++i) should be an lvalue. If it is legal then why does the posfix operator have a higher precedence than the prefix operator? Oct 09 2006
It's a bug in DMC++ "Sz. Horvát" <szhorvat-nospamplease gmail.com> wrote in message news:egdsnm$jvm$1 digitaldaemon.com...Okay, I know that this is a stupid question, but I am curious: Should the following be legal? #include <iostream> using namespace std; int main() { int i = 0; (++i)++; // <-- the question is about this cout << i << endl; return 0; } It does compile with gcc but not with dmc 8.49. I thought that (++i) should be an lvalue. If it is legal then why does the posfix operator have a higher precedence than the prefix operator? Oct 10 2006
On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:"Sz. Horvát" <szhorvat-nospamplease gmail.com> wrote in message news:egdsnm$jvm$1 digitaldaemon.com...Okay, I know that this is a stupid question, but I am curious: Should the following be legal? #include <iostream> using namespace std; int main() { int i = 0; (++i)++; // <-- the question is about this cout << i << endl; return 0; } It does compile with gcc but not with dmc 8.49. I thought that (++i) should be an lvalue. If it is legal then why does the posfix operator have a higher precedence than the prefix operator? Oct 10 2006
On Wed, 11 Oct 2006 09:29:17 +1000, Derek Parnell wrote:On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:It's a bug in DMC++ Oct 10 2006
"Derek Parnell" <derek nomail.afraid.org> wrote in message news:pykh8vjb00oz$.1vipkpdvx9igh$.dlg 40tude.net...On Wed, 11 Oct 2006 09:29:17 +1000, Derek Parnell wrote:On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:It's a bug in DMC++ Oct 10 2006
"Derek Parnell" <derek nomail.afraid.org> wrote in message news:texhpcyj3e5c.x2tpmo3z3l60.dlg 40tude.net...On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:"Sz. Horvát" <szhorvat-nospamplease gmail.com> wrote in message news:egdsnm$jvm$1 digitaldaemon.com...Okay, I know that this is a stupid question, but I am curious: Should the following be legal? #include <iostream> using namespace std; int main() { int i = 0; (++i)++; // <-- the question is about this cout << i << endl; return 0; } It does compile with gcc but not with dmc 8.49. I thought that (++i) should be an lvalue. If it is legal then why does the posfix operator have a higher precedence than the prefix operator? Oct 10 2006
Matthew wrote:"Derek Parnell" <derek nomail.afraid.org> wrote in message news:texhpcyj3e5c.x2tpmo3z3l60.dlg 40tude.net...On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:"Sz. Horvát" <szhorvat-nospamplease gmail.com> wrote in message news:egdsnm$jvm$1 digitaldaemon.com...Okay, I know that this is a stupid question, but I am curious: Should the following be legal? #include <iostream> using namespace std; int main() { int i = 0; (++i)++; // <-- the question is about this cout << i << endl; return 0; } It does compile with gcc but not with dmc 8.49. I thought that (++i) should be an lvalue. If it is legal then why does the posfix operator have a higher precedence than the prefix operator? Oct 10 2006
Sean Kelly wrote:Wouldn't this make your examples above illegal? Oct 11 2006
On Wed, 11 Oct 2006 10:12:00 +1000, Matthew wrote:"Derek Parnell" <derek nomail.afraid.org> wrote in message news:texhpcyj3e5c.x2tpmo3z3l60.dlg 40tude.net...On Wed, 11 Oct 2006 07:37:50 +1000, Matthew wrote:It's a bug in DMC++ Oct 10 2006
|