[HACKERS] "left shift of negative value" warnings
От | Andres Freund |
---|---|
Тема | [HACKERS] "left shift of negative value" warnings |
Дата | |
Msg-id | 20170409220102.4qvj4z64zkyxc74k@alap3.anarazel.de обсуждение исходный текст |
Ответы |
Re: [HACKERS] "left shift of negative value" warnings
|
Список | 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
В списке pgsql-hackers по дате отправления: