| From: | Grant Jurgensen <grant(at)kestrel(dot)edu> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Incompatible declarations of pg_reg_getcolor() in regcomp.c and regexec.c |
| Date: | 2026-11-06 20:47:02 |
| Message-ID: | 7a0dc01d-a9fb-41e0-bc6a-38465e8f77e7@kestrel.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
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(at)kestrel(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-11-06 22:10:27 | Re: BUG #19382: Server crash at __nss_database_lookup |
| Previous Message | Tom Lane | 2026-11-06 20:32:20 | Re: Incompatible declarations of pg_reg_getcolor() in regcomp.c and regexec.c |