This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/88479] sanitizer should provide an option to detect conversion to signed integer that overflows
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Dec 2018 20:52:00 +0000
- Subject: [Bug sanitizer/88479] sanitizer should provide an option to detect conversion to signed integer that overflows
- Auto-submitted: auto-generated
- References: <bug-88479-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88479
--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Thu, 13 Dec 2018, vincent-gcc at vinc17 dot net wrote:
> The C standard would have to drop ones' complement and sign-magnitude first.
And there's substantial support for doing so.
> In any case, this is not a good programming practice, and for some projects, it
If you want to do modulo arithmetic on signed values, the idiom (in
common-usage C which supports conversions to signed integer types as being
modulo) is to convert to unsigned, do arithmetic on unsigned and convert
back to signed. I don't think that's a bad practice. (Unintentional
overflows on conversion to signed would be bad, but the problem is
determining what's intentional.)