| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | "left shift of negative value" warnings |
| Date: | 2017-04-09 22:01:02 |
| Message-ID: | 20170409220102.4qvj4z64zkyxc74k@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
For a while I've been getting warnings like
/home/andres/src/postgresql/src/backend/utils/adt/inet_cidr_ntop.c: In function ‘inet_cidr_ntop_ipv6’:
/home/andres/src/postgresql/src/backend/utils/adt/inet_cidr_ntop.c:205:11: warning: left shift of negative value [-Wshift-negative-value]
m = ~0 << (8 - b);
^~
/home/andres/src/postgresql/src/backend/utils/adt/network.c: In function ‘inetmi’:
/home/andres/src/postgresql/src/backend/utils/adt/network.c:1482:24: warning: left shift of negative value [-Wshift-negative-value]
res |= ((int64) -1) << (byte * 8);
^~
/home/andres/src/postgresql/src/backend/utils/adt/varbit.c: In function ‘bitfromint4’:
/home/andres/src/postgresql/src/backend/utils/adt/varbit.c:1546:16: warning: left shift of negative value [-Wshift-negative-value]
val |= (-1) << (srcbitsleft + 8 - destbitsleft);
^~
/home/andres/src/postgresql/src/backend/utils/adt/varbit.c: In function ‘bitfromint8’:
/home/andres/src/postgresql/src/backend/utils/adt/varbit.c:1626:16: warning: left shift of negative value [-Wshift-negative-value]
val |= (-1) << (srcbitsleft + 8 - destbitsleft);
If I understand C99 correctly, the behaviour of a left-shift of a
negative number is undefined (6.5.7 4.). In C89 the spec was very
unclear about that.
Greetings,
Andres Freund
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joe Conway | 2017-04-09 22:01:42 | Re: partitioned tables and contrib/sepgsql |
| Previous Message | Thomas Munro | 2017-04-09 21:55:19 | Re: [sqlsmith] Planner crash on foreign table join |