STL icon indicating copy to clipboard operation
STL copied to clipboard

`<utility>`: Cv-qualified integer types are incorrectly accepted in some places

Open frederick-vs-ja opened this issue 1 year ago • 3 comments

Describe the bug

As clarify by the NAD status of CWG-251, whenever the standard says "signed or unsigned integer type" or "standard integer type", only cv-unqualified versions are included.

So it's incorrect to use remove_cv_t<_Ty> here, and the original _Ty should be used instead.

https://github.com/microsoft/STL/blob/2e27f1f05a155bb3637dad04b4d9c4c4590c8542/stl/inc/utility#L951-L953

Currently, integer comparison functions in <utility> and std::extents (in <mdspan>) are affected.

Command-line test case

Godbolt link

#include <mdspan>
#include <utility>

static_assert(std::cmp_less<const int, const int>(0, 1)); // should be rejected
static_assert(sizeof(std::extents<const int, 42>)); // should be rejected

Expected behavior

The example should not compile.

STL version

Probably all existing versions since 48f79a3112ab15a2a9018bc9ec71f5d41a6b058e.

Additional context

This seemingly fits into https://github.com/microsoft/STL/labels/good%20first%20issue to me.

frederick-vs-ja avatar Nov 29 '25 11:11 frederick-vs-ja

Is this intended to be fixed ASAP? Or do we want to leave it for some newcomer?

I (or anyone, really) could handle it ASAP, just let me know; otherwise, marking it https://github.com/microsoft/STL/labels/good%20first%20issue would be appropriate IMO.

vmichal avatar Dec 05 '25 18:12 vmichal

I'd prefer to just fix this ASAP. Helping totally new contributors through good-first-issues is time-consuming.

StephanTLavavej avatar Dec 06 '25 00:12 StephanTLavavej

Will put a PR in 10

smundhra-git avatar Dec 07 '25 01:12 smundhra-git