- Title
- INT_MIN % -1
- Status
- cd3
- Section
- 7.6.5 [expr.mul]
- Submitter
- Richard Smith
Created on 2012-01-31.00:00:00 last changed 152 months ago
Messages
Date: 2012-10-15.00:00:00
[Moved to DR at the October, 2012 meeting.]
Date: 2012-02-15.00:00:00
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.
Date: 2026-07-25.21:52:10
Issue 614 adopted the corresponding C99
wording for 7.6.5 [expr.mul] paragraph 4, 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: Should C++ adopt similar wording?
...if the quotient a/b is representable in the type of the result,
(a/b)*b + a%b is equal to a .
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.
| 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 | |