A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cplusplus/CWG/issues/479 below:

CWG2855 [expr.post.incr] has no integral promotion, [expr.pre.incr] has · Issue #479 · cplusplus/CWG · GitHub

Full name of submitter: Lénárd Szolnoki

Reference (section label): [expr.post.incr]

The value of the operand object is modified by adding 1 to it.

Issue description

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 to x+=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.

Implementations

GCC, clang and MSVC accept both examples above in constant expressions. They otherwise detect overflowing increments when no promotion is involved.

Suggested resolution

Spell 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