Re: Side effects in conditional expressions

On 2010-10-02 00:08, Chïna Blüe Öyster Cult wrote:
In article<i85kc7\$mcj\$1@xxxxxxxxxxxxxxxxx>,
August Karlstrom<fusionfile@xxxxxxxxx> wrote:

(x == 0)? x++: y *= 2;

Can you guarentee what will be assigned to what if x==0 or x==1? If not, you

Also x++ is a rvalue, not an lvalue, so even if ?: has been extended to lvalues,
this won't work.

OK, I apparently need parentheses around `y *= 2' so it should read

(x == 0)? x++: (y *= 2);

/August

--
The competent programmer is fully aware of the limited size of his own skull. He therefore approaches his task with full humility, and avoids clever tricks like the plague. --Edsger Dijkstra
.

Relevant Pages

• Re: Side effects in conditional expressions
... Chïna Blüe Öyster Cult wrote: ... Would this be considered bad coding style? ... Also x++ is a rvalue, not an lvalue, so even if ?: ...
(comp.lang.c)
• Re: Side effects in conditional expressions
... Vincenzo Mercuri wrote: ... Would this be considered bad coding style? ... Also x++ is a rvalue, not an lvalue, so even if ?: ...
(comp.lang.c)
• Re: r- r-value vs l-value?
... bis an lvalue ... a+5 is an rvalue ... an rvalue-to-lvalue conversion occurs (and this conversion is ... It expects an rvalue operand and yields an lvalue which designates the ...
(comp.lang.c)
• Re: string literal is an lvalue; other literals are rvalues.
... >> As I understand the distinction between rvalue and lvalue, ... but not of an rvalue. ... such as the int value 5. ... There is talk of lvalue to rvalue conversion in 4.1. ...
(comp.lang.cpp)
• Re: Managed C++ Code Generation Bug?
... >> binds directly without an initial conversion to an rvalue, ... My mom always told me to stay out of lvalue vs. rvalue ... >I don't see why treating a static const member as an lvalue should cause ...
(microsoft.public.dotnet.languages.vc)