[Issue 3378] [tdpl] ++x should be an lvalue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 4 02:40:40 PST 2010


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



--- Comment #5 from Walter Bright <bugzilla at digitalmars.com> 2010-03-04 02:40:29 PST ---
C99 says this about ++x:

-------6.5.3.1-------------
The operand of the prefix increment or decrement operator shall have qualified
or unqualified real or pointer type and shall be a modifiable lvalue.

Semantics

The value of the operand of the prefix ++ operator is incremented. The result
is the new value of the operand after incrementation. The expression ++E is
equivalent to (E+=1). See the discussions of additive operators and compound
assignment for information on constraints, types, side effects, and conversions
and the effects of operations on pointers. The prefix -- operator is analogous
to the prefix ++ operator, except that the value of the operand is decremented.
--------6.5.16-------------------
An assignment expression has the value of the left operand after the
assignment, but is not an lvalue.
---------------------------------

It is equivalent to x+=1, and therefore not an lvalue.

The C++98 spec also says that ++x is equivalent to x+=1, but says that the
result of x+=1 is an lvalue.

-- 
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