Skip to content

[class.spaceship]/3 operation order is unclear #2748

@CaseyCarter

Description

@CaseyCarter

The subject paragraph:

The return value V of type R of the defaulted three-way comparison operator function with parameters x and y of the same type is determined by comparing corresponding elements x_i and y_i in the expanded lists of subobjects for x and y until the first index i where x_i <=> y_i yields a result value v_i where v_i != 0, contextually converted to bool, yields true; V is v_i converted to R. If no such index exists, V is std::strong_ordering::equal converted to R.

is clear that corresponding elements are compared, and that the process of comparison must terminate, but specifies neither the order in which indices within the list of subobjects are chosen nor that said sequence of chosen indices contains no duplicates. It's almost certainly the intent that corresponding pairs of elements are compared in order of increasing subscript, but that doesn't seem to be mandated.

#2729 adds similar wording elsewhere with the same issue. Could we clarify these editorially, or does this need a core issue?

Metadata

Metadata

Assignees

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