Skip to content

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

Description

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.

STL/stl/inc/utility

Lines 951 to 953 in 2e27f1f

template <class _Ty>
constexpr bool _Is_standard_integer = _Is_any_of_v<remove_cv_t<_Ty>, signed char, short, int, long, long long,
unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>;

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 48f79a3.

Additional context

This seemingly fits into good first issue Good for newcomers to me.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions