Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread John Regehr
On 8/3/2010 4:08 PM, Tom Lane wrote: However, most of the cases that seem of interest so far are in fairly small, stable functions. Would it be reasonable to attach a "checked for overflow problems" label to these functions as a whole? This should work great. I'll get my clang hacker to start

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread John Regehr
Tom, would you be willing to isolate these operations into functions that could be marked with a "no_overflow_check" attribute? This would be easy for us to deal with, would survive preprocesing cleanly, and wouldn't have any performance cost since inliners do a fine job. John On 8/3/2010

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread John Regehr
Just to follow up: all the other ones seem to be non-problems. Would you folks be willing to specify which arithmetic operations are considered to be safe in the case of overflow? Something simple like an "INTEGER_OVERFLOW_OK" comment at the end of the line of code containing the operation w

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread Tom Lane
John Regehr writes: > Tom, would you be willing to isolate these operations into functions > that could be marked with a "no_overflow_check" attribute? This would > be easy for us to deal with, would survive preprocesing cleanly, and > wouldn't have any performance cost since inliners do a fin

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread Tom Lane
John Regehr writes: >> Just to follow up: all the other ones seem to be non-problems. > Would you folks be willing to specify which arithmetic operations are > considered to be safe in the case of overflow? Something simple like an > "INTEGER_OVERFLOW_OK" comment at the end of the line of code

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread Tom Lane
Greg Stark writes: > On Tue, Aug 3, 2010 at 3:33 AM, Tom Lane wrote: >> Since this is a nearly-dead legacy datatype, I can't get excited about >> spending a lot of time on it.  What I suggest we do is do the difference >> calculation in int64 arithmetic instead of int32. > At some level this is

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-03 Thread Greg Stark
On Tue, Aug 3, 2010 at 3:33 AM, Tom Lane wrote: > Although this is the worst case, you could easily get overflows from > intervals with ordinary endpoints that are sufficiently far apart. Oh, duh, this is pretty obvious in retrospect. > Since this is a nearly-dead legacy datatype, I can't get ex

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-02 Thread Tom Lane
Greg Stark writes: > On Mon, Aug 2, 2010 at 7:16 PM, John Regehr wrote: >> : Op: -, Reason : Signed Subtraction Overflow, >> BINARY OPERATION: left (int32): 2147483644 right (int32): -2147483648 >> >> : Op: -, Reason : Signed Subtraction Overflow, >> BINARY OPERATION: left (int32): 2147483644

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-02 Thread Tom Lane
Greg Stark writes: > On Mon, Aug 2, 2010 at 7:16 PM, John Regehr wrote: >> : Op: -, Reason : Signed Subtraction Overflow, >> BINARY OPERATION: left (int32): 2147483644 right (int32): -2147483648 >> >> : Op: -, Reason : Signed Subtraction Overflow, >> BINARY OPERATION: left (int32): 2147483644

Re: [BUGS] BUG #5592: list of integer undefined behaviors

2010-08-02 Thread Greg Stark
On Mon, Aug 2, 2010 at 7:16 PM, John Regehr wrote: > : Op: -, Reason : Signed Subtraction Overflow, > BINARY OPERATION: left (int32): 2147483644 right (int32): -2147483648 > > : Op: -, Reason : Signed Subtraction Overflow, > BINARY OPERATION: left (int32): 2147483644 right (int32): -2147483648 >