Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread Tom Lane
I wrote: > "John Regehr" writes: >> During a "make check" the left-shift operator at tsquery_util.c 48:18 is >> passed a negative right-hand argument a number of times. > Hmm. valcrc is declared as signed int32, so depending on what your > compiler thinks the semantics of % is, this clearly can

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread John Regehr
Aha-- the -fwrapv flag (which I had though was a nop) screws up our checks. Another rough edge to fix. Removing this flag caused us to find a bunch of integer overflows. I'll start reporting them later today. John -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make chang

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread John Regehr
Tom, on the list you said: "I would be ecstatic if we could write int4pl like this: if (sum_overflows(arg1, arg2)) elog(ERROR, "overflow"); else return arg1 + arg2; " This is effectively what our clang patch does (automatically, for all integer o

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread John Regehr
Hrm, I'd have expected you to see a few integer overflows during the regression tests --- we do test that the overflow checks in places like int4pl work. I saw no signed overflows. Our patch still has some rough edges, but this part is pretty well tested. Perhaps the int4pl checks fire befor

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread Tom Lane
John Regehr writes: > On 08/02/2010 09:06 AM, Tom Lane wrote: >> John: how did you detect this? > One of my students has hacked Clang to detect integer undefined > behaviors in C, like this shift problem or signed overflows. Cool. > This was > the only problem that came up during a "make check"

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread John Regehr
Hi Tom, One of my students has hacked Clang to detect integer undefined behaviors in C, like this shift problem or signed overflows. This was the only problem that came up during a "make check" of a postgresql with this checking turned on, which is pretty cool. I'd expect to be able to find more

Re: [BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread Tom Lane
"John Regehr" writes: > Bug reference: 5590 > Logged by: John Regehr > Email address: reg...@cs.utah.edu > PostgreSQL version: head 8/2/10 > Operating system: OSX > Description:undefined shift behavior > Details: > During a "make check" the left-shift operator at tsq

[BUGS] BUG #5590: undefined shift behavior

2010-08-02 Thread John Regehr
The following bug has been logged online: Bug reference: 5590 Logged by: John Regehr Email address: reg...@cs.utah.edu PostgreSQL version: head 8/2/10 Operating system: OSX Description:undefined shift behavior Details: During a "make check" the left-shift operator a