Re: fun with ?:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 24, 2007 at 12:29:43AM +0100, Derek M Jones wrote:

> It was intended as a probabilit statement (ok, I did not make that
> clear).  An expression containing n+n is more likely to overflow
> than one containing n-n.

Gimme a break.
	a) s/int/unsigned and run that through gcc; no change in behaviour
	b) no fscking way in hell *either* is acceptable for bitfield
width - definitely not with -std=c99 -pedantic.  Violates 6.6p6 and 6.7.2.1p3.
	c) what's happening is pretty obvious - the difference is not in
overflows, it's in expression tree structure (remember, + and - are
left-to-right).  gcc throws several cheap optimizations at the expression
and checks if it has come up with a constant.  Simple common factors are taken
out (n*m - n*m is seen as 0), common subexpressions are not recognized
((n+m)-(n+m) is not seen as constant).
	d) (c) is an exercise in software proctology - gcc has an obvious
bug in that area (mishandling recognition of integer constant expressions),
period.
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux