Keep compiler silence (clang 10, implicit conversion from 'long' to'double' )

Поиск
Список
Период
Сортировка
От Yuya Watari
Тема Keep compiler silence (clang 10, implicit conversion from 'long' to'double' )
Дата
Msg-id CAJ2pMkbkkFw2hb9Qb1Zj8d06EhWAQXFLy73St4qWv6aX=vqnjw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Keep compiler silence (clang 10, implicit conversion from 'long'to 'double' )  (Yuya Watari <watari.yuya@gmail.com>)
Список pgsql-hackers
Hello,

I found the problem that clang compiler introduces warnings when building PostgreSQL. Attached patch fixes it.

===
Compiler version
===
clang version 10.0.0-svn372772-1~exp1+0~20190924181208.2504~1.gbpb209ff (trunk)

Older versions of clang may not generate this warning.

===
Warning
===

timestamp.c:3236:22: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
        if (result_double > PG_INT64_MAX || result_double < PG_INT64_MIN)
                          ~ ^~~~~~~~~~~~
../../../../src/include/c.h:444:22: note: expanded from macro 'PG_INT64_MAX'
#define PG_INT64_MAX    INT64CONST(0x7FFFFFFFFFFFFFFF)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../src/include/c.h:381:25: note: expanded from macro 'INT64CONST'
#define INT64CONST(x)  (x##L)
                        ^~~~
<scratch space>:234:1: note: expanded from here
0x7FFFFFFFFFFFFFFFL
^~~~~~~~~~~~~~~~~~~
1 warning generated.
pgbench.c:1657:30: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
                if (dval < PG_INT64_MIN || PG_INT64_MAX < dval)
                                           ^~~~~~~~~~~~ ~
../../../src/include/c.h:444:22: note: expanded from macro 'PG_INT64_MAX'
#define PG_INT64_MAX    INT64CONST(0x7FFFFFFFFFFFFFFF)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../src/include/c.h:381:25: note: expanded from macro 'INT64CONST'
#define INT64CONST(x)  (x##L)
                        ^~~~
<scratch space>:252:1: note: expanded from here
0x7FFFFFFFFFFFFFFFL
^~~~~~~~~~~~~~~~~~~
1 warning generated.

===

This warning is due to implicit conversion from PG_INT64_MAX to double, which drops the precision as described in the warning. This drop is not a problem in this case, but we have to get rid of useless warnings. Attached patch casts PG_INT64_MAX explicitly.

Thanks,
Yuya Watari
NTT Software Innovation Center
watari.yuya@gmail.com
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Implementing Incremental View Maintenance
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Remove page-read callback from XLogReaderState.