Created on 2012-01-31.00:00:00 last changed 130 months ago
[Moved to DR at the October, 2012 meeting.]
Proposed resolution (February, 2012):
Change 7.6.5 [expr.mul] paragraph 4 as follows:
...If the second operand of / or % is zero the behavior is undefined. For integral operands the / operator yields the algebraic quotient with any fractional part discarded;81 if the quotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a; otherwise, the behavior of both a/b and a%b is undefined.
Issue 614 adopted the corresponding C99 wording for 7.6.5 [expr.mul] paragraph 4,
...if the quotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a.
in an attempt to ensure that INT_MAX % -1 produces undefined behavior (because the result is not specified by the Standard). However, the new C draft makes the undefined behavior explicit:
If the quotient a/b is representable, the expression (a/b) * b + a%b shall equal a; otherwise, the behavior of both a/b and a%b is undefined.
Should C++ adopt similar wording?
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: drwp -> cd3 |
2013-05-03 00:00:00 | admin | set | status: dr -> drwp |
2012-11-03 00:00:00 | admin | set | messages: + msg4135 |
2012-11-03 00:00:00 | admin | set | status: ready -> dr |
2012-02-27 00:00:00 | admin | set | messages: + msg3705 |
2012-01-31 00:00:00 | admin | create |