https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122224

--- Comment #14 from Gast128 <gast128 at hotmail dot com> ---
(In reply to Jonathan Wakely from comment #13)
> (In reply to Gast128 from comment #12)
> > I would also prefer a compile time error if --it or (it - n) is not there
> > instead of routing it to ++it. One get a compilation error with
> > _GLIBCXX_CONCEPT_CHECKS but jwakely on Reddit (you?) stated that these
> > checks are broken.
> 
> Yes, they only check for the C++98 requirements, as I said in comment 9
> above.
We use GCC 14 so only the old checks are there. It was meant that there are
already some form of compile time checks present if turned on.

> I already explained above that a compile-time error is not going to happen,
> I consider it unacceptable.
> 
> But as also explained above, there is no "routing it to ++it" because it's
> now a no-op, or aborts with hardened checks enabled.

Pity. 

Our use case is like (for the std::views::transform):

if (!cnt.empty())
{
   int nLast = *std::prev(cnt.end());
   // etc.
}

The no-op would still end in a crash since the end iterator isn't decremented.

MSVC's implementation for std::advance is simpler with the random access
iterator using it + n or it - n and the other uses ++it or --it. This either
works or gives a compilation error if the iterator doesn't support it.

We will not use std::prev but just use --it ourselves which solves the problem.

Reply via email to