CWG Issue 661 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-04-13
661. Semantics of arithmetic comparisons
Section: 7.6.9 [expr.rel]Status: CD1Submitter: Daveed VandevoordeDate: 27 November 2007
[Voted into the WP at the June, 2008 meeting.]
The actual semantics of arithmetic comparison — e.g., whether 1 < 2 yields true or false— appear not to be specified anywhere in the Standard. The C Standard has a general statement that
Each of the operators < (less than), >(greater than), <= (less than or equal to), and >= (greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is false.
There is no corresponding statement in the C++ Standard.
Proposed resolution (February, 2008):
- Append the following paragraph to the end of 7.6.9 [expr.rel]:
If both operands (after conversions) are of arithmetic type, each of the operators shall yield true if the specified relation is true and false if it is false.
- Append the following paragraph to the end of 7.6.10 [expr.eq]:
Each of the operators shall yield true if the specified relation is true and false if it is false.