llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.73k stars 10.94k forks source link

[libc++] Poor diagnostic for signedness mismatch in std::ranges::iota #96794

Open ldionne opened 1 week ago

ldionne commented 1 week ago

From #91385:

The compiler error for the most common iota(0, vec.size()) with clang is not great. I was also wondering if instead of raising the error via a failure in the requires clause of the iota_view constructor guideline, it could be maybe raised earlier, e.g., from iota itself, with a nice message.

ldionne commented 1 week ago

As @frederick-vs-ja said in https://github.com/llvm/llvm-project/pull/96662#issuecomment-2190369463:

I've roughly tested the idea

  • extract a new _Integer_like_types_signedness_mismatch variable template,
  • use it in the constraints of the deduction guide, and then
  • copy the constraints of iota_view and its deduction guide to __iota::__fn::operator().

Error messages seem improved (Godbolt link).