BUG #18248: Expression is always zero

Started by PG Bug reporting formover 2 years ago5 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 18248
Logged by: RekGRpth
Email address: rekgrpth@gmail.com
PostgreSQL version: 16.1
Operating system: docker alpine
Description:

The value of expression 'thistimecnt >> 31 >> 31 >> 2' (in
src/timezone/zic.c) is zero regardless of the value of the left operand
'thistimecnt', because it is shifted by 64 (in total) bits, which is greater
or equal to its size of 64 bits.

Maybe this was what was meant?
thistimecnt >> 31 >> 2

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: PG Bug reporting form (#1)
Re: BUG #18248: Expression is always zero

On Thu, 2023-12-14 at 05:32 +0000, PG Bug reporting form wrote:

The value of expression 'thistimecnt >> 31 >> 31 >> 2' (in
src/timezone/zic.c) is zero regardless of the value of the left operand
'thistimecnt', because it is shifted by 64 (in total) bits, which is greater
or equal to its size of 64 bits.

Maybe this was what was meant?
thistimecnt >> 31 >> 2

This code is just taken from the GNU C library, and it's in our interest to
keep it as much aligned with upstram code as possible.

Yours,
Laurenz Albe

#3Julien Rouhaud
rjuju123@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #18248: Expression is always zero

Hi,

On Thu, Dec 14, 2023 at 05:32:49AM +0000, PG Bug reporting form wrote:

The value of expression 'thistimecnt >> 31 >> 31 >> 2' (in
src/timezone/zic.c) is zero regardless of the value of the left operand
'thistimecnt', because it is shifted by 64 (in total) bits, which is greater
or equal to its size of 64 bits.

Maybe this was what was meant?
thistimecnt >> 31 >> 2

Note that this is code imported as-is from upstream IANA tzcode, so we wouldn't
make any change ourself.

Looking at their git history they added it to remove some theoretical int
limits:
https://github.com/eggert/tz/commit/cc8aec6ecb1ecc3099f173e2bca9785ae8359c03

#4Alexander Lakhin
exclusion@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #18248: Expression is always zero

Hello Georgy,

14.12.2023 08:32, PG Bug reporting form wrote:

The following bug has been logged on the website:

Bug reference: 18248
Logged by: RekGRpth
Email address: rekgrpth@gmail.com

The value of expression 'thistimecnt >> 31 >> 31 >> 2' (in
src/timezone/zic.c) is zero regardless of the value of the left operand
'thistimecnt', because it is shifted by 64 (in total) bits, which is greater
or equal to its size of 64 bits.

Maybe this was what was meant?
thistimecnt >> 31 >> 2

I see the same in
https://github.com/eggert/tz/blob/main/zic.c

So maybe you would like to report that to the tz mailing list?:
https://www.iana.org/time-zones

Best regards,
Alexander

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Julien Rouhaud (#3)
Re: BUG #18248: Expression is always zero

Julien Rouhaud <rjuju123@gmail.com> writes:

On Thu, Dec 14, 2023 at 05:32:49AM +0000, PG Bug reporting form wrote:

The value of expression 'thistimecnt >> 31 >> 31 >> 2' (in
src/timezone/zic.c) is zero regardless of the value of the left operand

Note that this is code imported as-is from upstream IANA tzcode, so we wouldn't
make any change ourself.
Looking at their git history they added it to remove some theoretical int
limits:
https://github.com/eggert/tz/commit/cc8aec6ecb1ecc3099f173e2bca9785ae8359c03

Yeah, the tzcode crew have a wider range of (possibly theoretical)
target systems in mind than we do. They probably won't think this
is a bug, and we're unlikely to diverge from whatever they do.

regards, tom lane