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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Roman Lebedev from comment #0)
> I believe in the version 12, a new instance of such intentional wraparound
> was introduced into libstdc++: https://godbolt.org/z/rq153fxKW

No, that code is from 2014-12-19.

> I understand that there is no UB there.
> I understand that you are doing this intentionally.
> The problem is that it is happening in a header,
> so it's effectively dictating everyone
> that they should not use that sanitizer.

Well, they shouldn't use it *and expect everybody else's code to never rely on
unsigned wraparound*. If they want to write their own code to never rely on
that guaranteed feature of the language, that's fine. They don't get to force
that choice on everybody else.


> Silencing this kind of thing from user side is possible,
> but it's somewhat cumbersome: it requires compiling with
> `-fsanitize-recover=integer`, and supplying a run-time suppressions file.
> 
> On the other hand, suppressing this in-source is trivial:
> https://godbolt.org/z/E7sEnvvrT
> ... all it would take is applying
> `__attribute__((no_sanitize("unsigned-integer-overflow")))`
> to `_S_compare` on line 483 in `basic_string.h`.
> 
> I have tried that locally, and it works, but it seems it needs to be
> wrapped into `#if defined(__clang__)` preprocessor check:
> https://godbolt.org/z/5a7ox4EWv
> 
> Forwarded from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029970

So provide a patch then, instead of asking other people to work around this
sanitizer for you.

Reply via email to