On Sat, 26 Oct 2024 at 01:51, Andy Fan <zhihuifan1...@163.com> wrote: > > > 10). In this error: > > > > + elog(ERROR, "unsupported type %d for rand_array function.", > > + datatype); > > > > "datatype" is of type Oid, which is unsigned, and so it should use > > "%u" not "%d". Also, as above, it should not end with a period, so it > > should be: > > > > + elog(ERROR, "unsupported type %u for rand_array function", > > + datatype); > > All the following commands succeed without any warnings. > > clang -O0 -g main.c -o main -Wall -Wformat > gcc -g main.c -o main -Wall -Wformat >
This can be detected in gcc with -Wformat plus -Wformat-signedness flags. I see that this has been discussed before (e.g., [1]), but it doesn't look like those patches were committed, and there are still many such warnings, if you try compiling postgres with those flags. [1] https://www.postgresql.org/message-id/flat/CA%2BhUKGJ7EQm9extQAgrFZNNUKqRT8Vv5t1tKqA-5nEcYn0%2BwNA%40mail.gmail.com I don't know if anyone has any plans to pick up that work again, but in any case, it seems wise to not add more. Regards, Dean