Type assertions without GCC builtins

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Type assertions without GCC builtins
Date: 2025-11-15 00:06:42
Message-ID: CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Our assertion quality is lower on Visual Studio. I assumed there was
nothing stopping us from writing a pg_expr_has_type_p() macro using
pure standard C and C++ these days, and the attached patch seemed to
work on GCC, Clang and Visual Studio 2022 (via CI, no Windows here).

Unfortunately our unconstify() macro triggers internal errors on
Visual Studio 2019 with this applied:

[23:39:47.176] ../src/common/file_utils.c(712): fatal error C1001:
Internal compiler error.
[23:39:47.176] (compiler file 'msc1.cpp', line 1603)
[23:39:47.176] To work around this problem, try simplifying or
changing the program near the locations listed above.

Presumably _Generic type resolution and StaticAssertExpr()'s
definition are just too much for it. I wonder if some other phrasing
could help. Posting where I got to with this, in case anyone has any
ideas...

Attachment Content-Type Size
0001-Add-pg_expr_has_type_p-for-type-check-assertions.patch text/x-patch 9.8 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-11-15 00:23:11 Re: Remaining dependency on setlocale()
Previous Message Tomas Vondra 2025-11-14 23:00:06 Re: Performance issues with parallelism and LIMIT