This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] sext_hwi: Avoid left shift of negative value undefined behaviour
- From: Mike Stump <mikestump at comcast dot net>
- To: Jeff Law <law at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Mikael Morin <mikael dot morin at sfr dot fr>, Markus Trippelsdorf <markus at trippelsdorf dot de>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 12 Aug 2015 12:19:10 -0700
- Subject: Re: [Patch] sext_hwi: Avoid left shift of negative value undefined behaviour
- Authentication-results: sourceware.org; auth=none
- References: <55C33636 dot 7020907 at sfr dot fr> <55CA51C4 dot 3050601 at redhat dot com> <CAFiYyc1pM=BT06yLY=L9EDzDCSiUHeXL0D26ic-g8bnYBmqYNA at mail dot gmail dot com> <20150812110724 dot GB403 at x4> <CAFiYyc3G2NM2iqM5b5TKs+yWZJZ5-S13n30Bz51a2uMYL7N6KA at mail dot gmail dot com> <55CB4B40 dot 6040902 at sfr dot fr> <55CB7C0C dot 7030203 at redhat dot com> <F89F5949-3938-4F58-9C31-8BC0B217533B at gmail dot com> <55CB8B51 dot 5080908 at redhat dot com>
On Aug 12, 2015, at 11:07 AM, Jeff Law <law@redhat.com> wrote:
> On 08/12/2015 11:12 AM, Richard Biener wrote:
>>
>> Prec is almost never a constant and is heavily used from wide-int.
>>
>> We are not exploiting this undefined ness in C so I object to making this so much slower.
>>
>> Can we instead do what we do for abs_hwi and add a checking assert so we can move the tests to the callers that misbehave instead?
> Given that ISO C++ is moving away from making shifting 1 into the sign bit undefined behaviour, maybe we should make UBSan less strict in its warning. That may eliminate the need for Mikael's patch.
Pedantically, then, we have to move the the later language standard (if this was standardese). If it was DRese, then we’re safe. :-)