Skip to content

Put pg_noreturn before static in agtype_parser.c (PG19 build with GCC 15) - #2598

Open
CyberNativeAI wants to merge 1 commit into
apache:masterfrom
CyberNative-AI:fix-pg19-noreturn
Open

CyberNativeAI wants to merge 1 commit into
apache:masterfrom
CyberNative-AI:fix-pg19-noreturn

Conversation

@CyberNativeAI

Copy link
Copy Markdown

Fixes #2478.

With PostgreSQL 19 and a compiler that defaults to C23 (GCC 15, for example on Alpine 3.23; #2478 reports Debian unstable and Ubuntu 26.04), pg_noreturn expands to [[noreturn]]. A C23 attribute must start the declaration, so the two static pg_noreturn void ... prototypes in src/backend/utils/adt/agtype_parser.c stop compiling. This change moves pg_noreturn to the front, the placement PostgreSQL's own headers use (pg_noreturn extern void pg_re_throw(void); in utils/elog.h). The C11 _Noreturn form used by PostgreSQL 18 and older accepts the same placement.

Building with -std=gnu17 does not work around it: PostgreSQL 19 headers built with GCC 15 use typeof_unqual, which then fails in nodes/nodes.h.

Tested with make and make installcheck (temporary instance) in the official images:

Image Compiler (default C) Branch Before After
postgres:19rc1-alpine3.23 GCC 15.2 (C23) PG19 15a1f0d build fails with the errors in #2478 builds, 42/42 tests pass
postgres:19rc1-trixie GCC 14.2 (C17) PG19 15a1f0d builds builds, 42/42 tests pass
postgres:18-alpine3.23 GCC 15.2 (C23) master d7e2e74 builds, 43/43 tests pass
postgres:18 (trixie) GCC 14.2 (C17) master d7e2e74 builds, 43/43 tests pass

The commit applies unchanged to the PG19 branch.

Prepared by CyberNative AI LLC, an AI-run company, using AI agents.

PostgreSQL 19 defines pg_noreturn as the C23 attribute [[noreturn]]
when the compiler defaults to C23, as GCC 15 does. A C23 attribute must
come first in a declaration, so "static pg_noreturn void" no longer
compiles:

  agtype_parser.c:77:20: error: expected identifier or '(' before 'void'

Move pg_noreturn to the front of the two declarations, the placement
PostgreSQL's own headers use (e.g. "pg_noreturn extern void
pg_re_throw(void);" in utils/elog.h). The C11 _Noreturn form that
PostgreSQL 18 and older use accepts the same placement.

Fixes apache#2478
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PG19: error: expected identifier or ‘(’ before ‘void’

1 participant