Re: Change copyObject() to use typeof_unqual

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jelte Fennema-Nio <postgres@jeltef.nl>, Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-16T22:28:07Z
Lists: pgsql-hackers
Hi,

On Mon, Mar 16, 2026 at 8:32 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Jelte Fennema-Nio <postgres@jeltef.nl> writes:
> > On Mon, 16 Mar 2026 at 13:47, Peter Eisentraut <peter@eisentraut.org> wrote:
> >> I'm tempted to go with my proposed patch of a version-based override for
> >> the time being.
>
> > Sounds good to me.
>
> I confirmed that Peter's
> 0001-Hardcode-override-of-typeof_unqual-for-clang-for-bit.patch
> fixes the problem on my Fedora 40 system.

I'm still encountering the following error while building from source
at commit f4af7849b3d when using autoconf:

execParallel.c:154:9: error: call to undeclared function
'typeof_unqual'; ISO C99 and later do not support implicit function
declarations [-Wimplicit-function-declaration]
  154 |         plan = copyObject(plan);
      |                ^
../../../src/include/nodes/nodes.h:230:27: note: expanded from macro
'copyObject'
  230 | #define copyObject(obj) ((typeof_unqual(*(obj)) *) copyObjectImpl(obj))
      |                           ^
execParallel.c:154:9: error: expected expression
../../../src/include/nodes/nodes.h:230:50: note: expanded from macro
'copyObject'
  230 | #define copyObject(obj) ((typeof_unqual(*(obj)) *) copyObjectImpl(obj))
      |                                                  ^
analyze.c:3213:27: error: call to undeclared function 'typeof_unqual';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
 3213 |                 stmt->into->viewQuery = copyObject(query);
      |                                         ^
../../../src/include/nodes/nodes.h:230:27: note: expanded from macro
'copyObject'
  230 | #define copyObject(obj) ((typeof_unqual(*(obj)) *) copyObjectImpl(obj))
      |                           ^
analyze.c:3213:27: error: expected expression
../../../src/include/nodes/nodes.h:230:50: note: expanded from macro
'copyObject'
  230 | #define copyObject(obj) ((typeof_unqual(*(obj)) *) copyObjectImpl(obj))
      |                                                  ^
2 errors generated.
:
(many similar errors)

I'm using Fedora 43 and gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7).
The issue doesn't happen when using meson+ninja.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add some const qualifiers enabled by typeof_unqual change on copyObject

  2. Hardcode typeof_unqual to __typeof_unqual__ for clang

  3. Clean up postgres_fdw/t/010_subscription.pl.

  4. Hardcode override of typeof_unqual for clang-for-bitcode

  5. Make typeof and typeof_unqual fallback definitions work on C++11

  6. Change copyObject() to use typeof_unqual

  7. Fixes for C++ typeof implementation

  8. Support using copyObject in standard C++