unconstify()/unvolatize() vs g++/clang++

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: unconstify()/unvolatize() vs g++/clang++
Date: 2023-12-11 00:42:48
Message-ID: CA+hUKGK3OXFjkOyZiw-DgL2bUqk9by1uGuCnViJX786W+fyDSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

AFAICS you can't use unconstify()/unvolatize() in a static inline
function in a .h file, or in a .cpp file, because
__builtin_types_compatible_p is only available in C, not C++. Seems
like a reasonable thing to want to be able to do, no? I'm not
immediately sure what the right fix is; would #if
defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) && !defined(__cplusplus)
around the relevant versions of constify()/unvolatize() be too easy?

HAVE__BUILTIN_TYPES_COMPATIBLE_P is also tested in relptr.h, but only
for further preprocessor stuff, not in functions that the compiler
will see, so cpluspluscheck doesn't have anything to reject, and
nothing will break unless someone writing C++ code actually tries to
use relptr_access(). I think we can live with that one?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-12-11 00:57:39 Some useless includes in llvmjit_inline.cpp
Previous Message Masahiko Sawada 2023-12-11 00:36:38 Re: Make COPY format extendable: Extract COPY TO format implementations