Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vFbFA-00EUfK-RX for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 16:47:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vFbF8-00CLVM-Qb for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 16:47:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vFbF8-00CLTZ-Ge for pgsql-hackers@lists.postgresql.org; Sun, 02 Nov 2025 16:47:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vFbF5-005bEr-0K for pgsql-hackers@lists.postgresql.org; Sun, 02 Nov 2025 16:47:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5A2GljIx428508; Sun, 2 Nov 2025 11:47:45 -0500 From: Tom Lane To: Bryan Green cc: pgsql-hackers@lists.postgresql.org Subject: Re: C nitpick about pgwin32_dispatch_queued_signals() In-reply-to: <9c55d148-17c5-4d3a-96a1-7ece939a202a@gmail.com> References: <9c55d148-17c5-4d3a-96a1-7ece939a202a@gmail.com> Comments: In-reply-to Bryan Green message dated "Sun, 02 Nov 2025 09:29:43 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <428506.1762102065.1@sss.pgh.pa.us> Date: Sun, 02 Nov 2025 11:47:45 -0500 Message-ID: <428507.1762102065@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryan Green writes: > On 11/2/2025 7:05 AM, Christian Ullrich wrote: >> the current MSVC compiler deems it necessary to issue >> warning C4053: one void operand for '?:' >> for a line with CHECK_FOR_INTERRUPTS(). This boils down to this bit of >> miscadmin.h (line 116 in master): >> >> #define INTERRUPTS_PENDING_CONDITION() \ >> (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? >> pgwin32_dispatch_queued_signals() : 0, \ >> unlikely(InterruptPending)) >> #endif >> >> The C spec says that of the possible results of the :? operator, either >> none or both can be void, and pgwin32_dispatch_queued_signals() is void >> (and has been as far back as I can find it). > Yeah, this is a bug, or at least a spec violation. We should fix it in > my opinion-- it's non-conforming C. Others may disagree, though. Agreed. > 2. Restructure to use && instead of ?:: > #define INTERRUPTS_PENDING_CONDITION() \ > (unlikely(UNBLOCKED_SIGNAL_QUEUE()) && \ > (pgwin32_dispatch_queued_signals(), true), \ > unlikely(InterruptPending)) > I'd lean towards #2 --- it's cleaner and avoids the whole issue. I dunno, don't really like the nested comma operator here. It's probably necessary to avoid having a void argument to &&, but it's confusing. Let's go with your #1 (casting the 0 to void). But can't we simplify that to just #define INTERRUPTS_PENDING_CONDITION() \ (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? pgwin32_dispatch_queued_signals() : (void) 0, \ unlikely(InterruptPending)) #endif that is, the only change needed is s/0/(void) 0/. regards, tom lane