Re: BUG #5237: strange int->bit and bit->int conversions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org>, kononov(at)ftml(dot)net
Subject: Re: BUG #5237: strange int->bit and bit->int conversions
Date: 2009-12-12 19:28:39
Message-ID: 11277.1260646119@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> I'm not sure this fixes it, although I haven't tested. When we take
>> the /* store first fractional byte */ branch, destbitsleft is between
>> 1 and 7 bits greater than srcbitsleft. We then subtract 8 from
>> destbitsleft, and the comment on the next line now asserts that the
>> two are equal. That doesn't seem right.

The comment's a bit bogus. What it should say, probably, is that the
*correct* value of srcbitsleft is now equal to destbitsleft so we aren't
bothering to track it anymore. If we were being fully anal we'd have
reduced srcbitsleft by some number less than 8 inside the if-branch.

>> Also, I thought about the sign extension problem, but aren't we
>> chopping those bits off anyway on the next line?

Nope, we'd have already stored the wrong bits into the output byte.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-12-12 19:29:51 Re: BUG #5238: frequent signal 11 segfaults
Previous Message Robert Haas 2009-12-12 19:17:48 Re: BUG #5237: strange int->bit and bit->int conversions

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2009-12-12 19:30:48 Re: Adding support for SE-Linux security
Previous Message Robert Haas 2009-12-12 19:17:48 Re: BUG #5237: strange int->bit and bit->int conversions