From: Grant Jurgensen <grant@kestrel.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Incompatible declarations of pg_reg_getcolor() in regcomp.c and regexec.c
Date: Fri, 6 Nov 2026 14:47:02 -0600
Message-ID: <7a0dc01d-a9fb-41e0-bc6a-38465e8f77e7@kestrel.edu> (raw)
In-Reply-To: <1905077.1793997140@sss.pgh.pa.us>
References: <13a01caf-c4de-454e-aefa-92260aac7e64@kestrel.edu>
<1905077.1793997140@sss.pgh.pa.us>
Hi Tom,
Thanks for taking a look. To address your question, the C17 standard
(6.2.7 p2) says:
All declarations that refer to the same object or function shall have
compatible type; otherwise, the behavior is undefined.
The undefined behavior comes from the declarations themselves, not from
any access to the field. Other versions of the standard say the same thing.
In practice you're right: neither pg_reg_getcolor() nor the executor
ever touches colormap.v, so there is no observable issue, and my
suggested rename doesn't change the compiled code at all. But it does
remove behavior that is technically undefined, which matters for
whole-program analysis tools that have to reconcile the two declarations
of the same external function. And it's an easy fix.
Thanks,
-Grant
On 11/6/26 2:32 PM, Tom Lane wrote:
> Grant Jurgensen <grant@kestrel.edu> writes:
>> The regex compiler and executor declare the external function
>> pg_reg_getcolor() with incompatible types, which is undefined behavior
>> under C17 6.2.7p2:
> Since pg_reg_getcolor doesn't touch the colormap.v field, I'm
> fairly confused about where there is any actual undefined behavior.
>
> regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: grant@kestrel.edu, tgl@sss.pgh.pa.us
Subject: Re: Incompatible declarations of pg_reg_getcolor() in regcomp.c and regexec.c
In-Reply-To: <7a0dc01d-a9fb-41e0-bc6a-38465e8f77e7@kestrel.edu>
References: <13a01caf-c4de-454e-aefa-92260aac7e64@kestrel.edu> <1905077.1793997140@sss.pgh.pa.us> <7a0dc01d-a9fb-41e0-bc6a-38465e8f77e7@kestrel.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox