Skip to content

CWG2981 [expr.arith.conv] 0 < 0 is an int #663

@eisenwave

Description

@eisenwave

Reference (section label): [expr.arith.conv] pargraph 1

Issue description

[expr.rel] paragraph 2 states that the result of the relational operator for e.g. 0 < 0 is bool. This is subsequently contradicted by [expr.rel] paragraph 3, which states that the usual arithmetic conversions are applied, and [expr.arith.conv] paragraph 1 states:

The purpose [of the usual arithmetic conversions] is to yield a common type, which is also the type of the result.

If paragraph 3 supersedes paragraph 2, then 0 < 0 is of type int.

Suggested resolution

Update [expr.arith.conv] paragraph 1 as follows:

Many binary operators that expect operands of arithmetic or enumeration type
cause conversions and yield result types in a similar way.
The purpose is to yield a common type
-, which
+; unless otherwise stated, that common type
is also the type of the result.
This pattern is called the usual arithmetic conversions, which are defined as follows:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions