This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] sext_hwi: Avoid left shift of negative value undefined behaviour


On Thu, Aug 13, 2015 at 03:52:00PM +0200, Markus Trippelsdorf wrote:
> 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

I see, both are UB.

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]