When compiling, I get the following warnings:
[338/2397] Compiling C object src/timezone/zic.p/zic.c.o
In file included from ../src/timezone/zic.c:22:
../src/timezone/private.h:187:9: warning: ‘unreachable’ redefined
187 | #define unreachable() pg_unreachable()
| ^~~~~~~~~~~
In file included from ../src/include/c.h:68,
from ../src/include/postgres_fe.h:28,
from ../src/timezone/zic.c:11:
/nix/store/hkldzpgigap7kkqzdr5j4qqyy5ac4l6x-gcc-16.1.0/lib/gcc/x86_64-unknown-linux-gnu/16.1.0/include/stddef.h:468:9:
note: this is the location of the previous definition
468 | #define unreachable() (__builtin_unreachable ())
| ^~~~~~~~~~~
[1218/2397] Compiling C object
src/backend/postgres_lib.a.p/.._timezone_strftime.c.o
In file included from ../src/timezone/strftime.c:45:
../src/timezone/private.h:187:9: warning: ‘unreachable’ redefined
187 | #define unreachable() pg_unreachable()
| ^~~~~~~~~~~
In file included from ../src/include/c.h:68,
from ../src/include/postgres.h:48,
from ../src/timezone/strftime.c:41:
/nix/store/hkldzpgigap7kkqzdr5j4qqyy5ac4l6x-gcc-16.1.0/lib/gcc/x86_64-unknown-linux-gnu/16.1.0/include/stddef.h:468:9:
note: this is the location of the previous definition
468 | #define unreachable() (__builtin_unreachable ())
| ^~~~~~~~~~~
[1225/2397] Compiling C object
src/backend/postgres_lib.a.p/.._timezone_localtime.c.o
In file included from ../src/timezone/localtime.c:24:
../src/timezone/private.h:187:9: warning: ‘unreachable’ redefined
187 | #define unreachable() pg_unreachable()
| ^~~~~~~~~~~
In file included from ../src/include/c.h:68,
from ../src/timezone/localtime.c:17:
/nix/store/hkldzpgigap7kkqzdr5j4qqyy5ac4l6x-gcc-16.1.0/lib/gcc/x86_64-unknown-linux-gnu/16.1.0/include/stddef.h:468:9:
note: this is the location of the previous definition
468 | #define unreachable() (__builtin_unreachable ())
| ^~~~~~~~~~~
[1310/2397] Compiling C object
src/bin/initdb/initdb.p/.._.._timezone_localtime.c.o
In file included from ../src/timezone/localtime.c:24:
../src/timezone/private.h:187:9: warning: ‘unreachable’ redefined
187 | #define unreachable() pg_unreachable()
| ^~~~~~~~~~~
In file included from ../src/include/c.h:68,
from ../src/timezone/localtime.c:17:
/nix/store/hkldzpgigap7kkqzdr5j4qqyy5ac4l6x-gcc-16.1.0/lib/gcc/x86_64-unknown-linux-gnu/16.1.0/include/stddef.h:468:9:
note: this is the location of the previous definition
468 | #define unreachable() (__builtin_unreachable ())
| ^~~~~~~~~~~
The upstream code for private.h's definition of unreachable() looks
quite a bit different than ours[0]. Seems like maybe our defintion was
over simplified. I don't actually know how the code is pulled in.
Attached it a potential solution based on how we protect the
static_assert definition in the same file.
[0]:
https://github.com/eggert/tz/blob/e14ee1cb61ca948b45f928ad187eaecc5a92d27e/private.h#L1055-L1069
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
diff --git i/src/timezone/private.h w/src/timezone/private.h
index 0d02e620b6..2a9f22816a 100644
--- i/src/timezone/private.h
+++ w/src/timezone/private.h
@@ -184,7 +184,9 @@
*/
#define INITIALIZE(x) ((x) = 0)
+#if __STDC_VERSION__ < 202311 && !defined unreachable
#define unreachable() pg_unreachable()
+#endif
/*
* For the benefit of GNU folk...