Opened 9 years ago

Closed 8 years ago

#9929 closed Bugs (invalid)

Bugfix: comparison involving different types

Reported by: gonzalobg88@… Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

difference_type does not necessary need to be of type int or size_t

There is a pull request with a patch in: URL_OF_BOOST_RANGE_AT_GITHUB/pull/3 (sorry but for some reason links to pull requests are rejected...)

Change History (3)

comment:1 by Marshall Clow, 9 years ago

But I do believe that it has to be a "signed integer type"

See [iterator.requirements.general]/p1; the last sentence:

For every iterator type X for which equality is defined, there is a corresponding signed integer type called the difference type of the iterator.

See also [basic.fundamental]/p2, which says:

There are five standard signed integer types : “signed char”, “short int”, “int”, “long int”, and “long long int”.

comment:2 by gonzalobg88@…, 9 years ago

But does it say that user-defined signed integer types are not allowed?

This is just debug code (inside a BOOST_ASSERT), and IMO the problem here is relying on implicit conversions.

Why is this debug code comparing a difference_type which is typically std::ptrdiff_t with an int? Doesn't it make sense to construct a difference_type since it is going to be compared with one anyways?

comment:3 by Marshall Clow, 8 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.