Full name of submitter: Lénárd Szolnoki
Reference (section label): [expr.post.incr]
Issue descriptionThe value of the operand object is modified by adding
1
to it.
consider:
This has undefined behavior: the value is increased by 1 but the resulting value is not representable in int8_t [expr.pre].
In comparison [expr.pre.incr] in addition has:
The expression
++x
is equivalent tox+=1
.
Which in turn is equivalent to x = x + 1
, except that x
is evaluated only once. This implies that integral promotion rules are considered.
Because of this the following is defined:
where ++x
is equivalent to x = (int)x + 1
.
GCC, clang and MSVC accept both examples above in constant expressions. They otherwise detect overflowing increments when no promotion is involved.
Suggested resolutionSpell out that the side effects of post-increment are equivalent to the side-effects of pre-increment, with the implied integral promotions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4