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 1vFa1T-00EAYv-Ty for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 15:29:39 +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 1vFa1S-00BsXD-PN for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Nov 2025 15:29:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vFa1S-00BsX4-FQ for pgsql-hackers@lists.postgresql.org; Sun, 02 Nov 2025 15:29:37 +0000 Received: from mail-yx1-xb130.google.com ([2607:f8b0:4864:20::b130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vFa1P-0053qp-2h for pgsql-hackers@lists.postgresql.org; Sun, 02 Nov 2025 15:29:36 +0000 Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-63e19642764so3786524d50.1 for ; Sun, 02 Nov 2025 07:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762097374; x=1762702174; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=Y12EiQ9JpdsB7jrdFrfnM/fhuaGECuuStYtOI4PpdB4=; b=RVQWRdvGFhtVdUCqL0RrnRmbcXgY3VSjKhd1EE8dwfYKuEmxY1KonfENWaFwQYIVmp 8Whf+tdAGgTUF8I7pnI3SD18WTORbFO46WTX+dzRiZrFeDRXqKvy2oUrSIytvp3ajbSM blnkcOVuG/Pe8iaqEgynkLV9yl4x6aRw85MUoFvNfRZw8Cuuv6PZBGPxO1/qDDKHuRmV CkCfUP1HrxYajRmy0P8/938bWqtJLHQkqpLr6z9LvxliXznPTs8UY7haogYXJvr75Bp1 K1oCK/OGFZe3Qu9vX91mGR/x4nuoJYmZ8XulQLfEQcQ1BLDP2bac6wfvDwO9DGV5q07A HsJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762097374; x=1762702174; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y12EiQ9JpdsB7jrdFrfnM/fhuaGECuuStYtOI4PpdB4=; b=LXXPNb9eG8t3BTO26k0/9IuLx3J4BH+TCpGhf+cznwV4G1tTM4/4SFpChdL+jX7eLJ HQdVWxxs+VU3pQ4TmB+quDMzig7YD+U8RDeCjLcg0sbf2FKVWaXwcXN7J8BbZCt7ImW+ iy3z+SdgDTg915q2DnXtlfdU0LSkm5XWHD1i0eegSOXjHFtUsMVt7DRfuRcyxQGXINBL ZkBUTArO0ABxJLBR4UXWZUi28zSfSZyPz1eUBl7gFi0jZBiQfZFEyjNPeIjAXLloNWNI xocxQ51ld9QU4pJsqQL5lnEEHpk0UqDEZTrtuTPax6zxrxc3TAphN1VvfahCioJWzCuf Hgqg== X-Gm-Message-State: AOJu0YwuA6tqy83MshVLg8xynt7cJgK+kiwxAmrVXZNDBz/uK8LZQNk9 26WdB2ZnNq0E2MoYfbGH23VLD/uhYMnsw2jmSQHAayO5aTR/fRw65m42MqXNeM1RkQdJOA== X-Gm-Gg: ASbGncvamEpAk5slEMbjBQdf6RNKFXi3KGKbg6gdgJXHBM4lKOBADBmVizx1Zz3B1oX 38WMtKMtRxM1hrUN526/QF84Kw252VAmbmBY03CXlToP0nicRYcFmEzVJwrmAc7FsHaT344r8IC 2pccm76rXDGWUBPmlvGbFLOFX/9V5fRTOxiC68lJ/Mr4DBCjPnY+wm438ylcTS9JN1h27tRLqXw nShOVvdPEPrUqI6Ban1iO1cO6UmF/gj/JWgkvbHdAAlzfZQY0zGUPeI7/MTlHv+lbCCklLxYyxF 36mVkwThNaHIjgYyKfL+A7W0je2HbCvkGrksgar8lo9Bxnv7xQxO0FzrkPqDRMGSQNekmVUEX+E Q/+6xpU0qQylYTr0kDyBBzYuGyrxovw0HqBI+ZpMEewES+7+fAPT7rXFgz7PVq8OhWjLgp1Bdqw gxNa3aicT7jNewlbTYSqqfa1qE8Q1gVnH0+HRfGIffESeejakRpva/y759+qWFl1/C X-Google-Smtp-Source: AGHT+IGbco1l7Iron/2A4aY9CQsjAEjanb4sGozNyapevMmtsgLIx//Ef3bnaWNYRGlBQy6jaNjPUw== X-Received: by 2002:a05:690c:2c09:b0:781:1c6b:feea with SMTP id 00721157ae682-7864858cabemr94811397b3.68.1762097373933; Sun, 02 Nov 2025 07:29:33 -0800 (PST) Received: from ?IPV6:2600:1700:8952:80:21f5:9e39:a0be:7530? ([2600:1700:8952:80:21f5:9e39:a0be:7530]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7864c6ac8bcsm22664017b3.56.2025.11.02.07.29.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Nov 2025 07:29:33 -0800 (PST) Message-ID: <9c55d148-17c5-4d3a-96a1-7ece939a202a@gmail.com> Date: Sun, 2 Nov 2025 09:29:43 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: C nitpick about pgwin32_dispatch_queued_signals() To: pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Bryan Green In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/2/2025 7:05 AM, Christian Ullrich wrote: > Hello, > > 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). > > Does that matter? > > 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. It happens to work because the comma operator discards the result anyway, but MSVC is right to complain. This isn't a new thing with modern C standards, BTW --- the rule about not mixing void and non-void operands in ?: has been there since C89. We've just been getting away with it because most compilers don't complain when the result is discarded by the comma operator anyway. I see a couple of ways to fix it: 1. Cast both arms to void: #define INTERRUPTS_PENDING_CONDITION() \ (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? \ (pgwin32_dispatch_queued_signals(), (void)0) : (void)0, \ unlikely(InterruptPending)) 2. Restructure to use && instead of ?:: #define INTERRUPTS_PENDING_CONDITION() \ (unlikely(UNBLOCKED_SIGNAL_QUEUE()) && \ (pgwin32_dispatch_queued_signals(), true), \ unlikely(InterruptPending)) 3. Just make it an inline function instead of a macro. I'd lean towards #2 --- it's cleaner and avoids the whole issue. The semantics are the same since we're only calling the function for its side-effects. Thoughts? Bryan Green