From: Daniel J. <dan...@gm...> - 2017-03-11 07:36:43
|
> > > As I said on 2017-02-08, diagnostics from -Wshift-negative-value are > > > most probably just noise. > > > > Why not disable them then? > > Feel free to do so. Good idea. Actually, this is is a very (very) bad idea. Applying a (left) shift to a negative value (or shifting by a negative value) is undefined behavior since (AFAIK) C99 (which is what we - at least in September - wanted to target). Quote from (C11) standard (draft) [1]: "The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. [..] If E1 has a signed type and nonnegative value [..] otherwise, the behavior is undefined." N1570 §6.5.7/4 Thus every single one of those warnings is a possible Heisenbug. Any random optimizer pass of any compiler could horribly break our code. We could force compilation without any optimization to reduce the risk of hitting such a case, but that's not really reasonable. [1]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf |