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: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Mikael Morin <mikael dot morin at sfr dot fr>, Jeff Law <law at redhat dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <rdsandiford at googlemail dot com>
- Date: Thu, 13 Aug 2015 15:52:00 +0200
- Subject: Re: [Patch] sext_hwi: Avoid left shift of negative value undefined behaviour
- Authentication-results: sourceware.org; auth=none
- References: <55CB7C0C dot 7030203 at redhat dot com> <F89F5949-3938-4F58-9C31-8BC0B217533B at gmail dot com> <55CB8B51 dot 5080908 at redhat dot com> <21C33A3D-9976-4632-ACCC-082F2D618ED5 at gmail dot com> <55CB9343 dot 6000103 at redhat dot com> <87k2t06zkk dot fsf at googlemail dot com> <55CC77D9 dot 9040101 at sfr dot fr> <20150813110816 dot GB386 at x4> <CAFiYyc0saOHRP8Z6J251eUmmxQK_58=CRhxh9p1s-2G4uU7AUw at mail dot gmail dot com> <20150813134032 dot GM3335 at redhat dot com>
On 2015.08.13 at 15:40 +0200, Marek Polacek wrote:
> On Thu, Aug 13, 2015 at 01:11:53PM +0200, Richard Biener wrote:
> > Rather ubsan should not complain about implementation defined behavior (or
> > should separate those cases out with a different switch compared to undefined
> > behavior).
>
> I think ubsan doesn't complain about implementation-defined behavior. It seems
> to me that in this thread it only (rightfully) complained about left-shifting of
> negative value.
There are two issues in the same location:
1) gcc/hwint.h:250:19: runtime error: left shift of 8589934588 by 32
places cannot be represented in type 'long int'
2) left-shifting of negative values
--
Markus