Build failure with GCC 15 (defaults to -std=gnu23)

Sam James <sam@gentoo.org>

From: Sam James <sam@gentoo.org>
To: pgsql-bugs@lists.postgresql.org
Date: 2024-11-17T02:54:01Z
Lists: pgsql-bugs
Hi,

postgres-17.1 fails to build with upcoming GCC 15 which defaults to
-std=gnu23 as follows:
```
In file included from ../../src/include/postgres_fe.h:25,
                 from checksum_helper.c:17:
../../src/include/c.h:456:23: error: two or more data types in declaration specifiers
  456 | typedef unsigned char bool;
      |                       ^~~~
../../src/include/c.h:456:1: warning: useless type name in empty declaration
  456 | typedef unsigned char bool;
      | ^~~~~~~
```

src/include/c.h does attempt to check for whether bool is already defined but
the check doesn't work.

There may be more issues afterwards but I haven't tried papering over
the above issue. It should be possible to reproduce w/
CFLAGS="... -std=gnu23" or CFLAGS="... -std=c23" on older GCC or Clang.

thanks,
sam



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Require sizeof(bool) == 1.

  2. If a C23 compiler is detected, try asking for C17.

  3. Fix C23 compiler warning

  4. Rename C23 keyword

  5. Assume that <stdbool.h> conforms to the C standard.

  6. Revise tree-walk APIs to improve spec compliance & silence warnings.