Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jrMrN-0008OP-IX for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 14:40:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jrMrM-0001vF-Dg for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 14:40:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jrMrM-0001v6-6E for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2020 14:40:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jrMrF-0003KJ-S0 for pgsql-hackers@postgresql.org; Fri, 03 Jul 2020 14:40:11 +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 063Ee0Ba931661; Fri, 3 Jul 2020 10:40:00 -0400 From: Tom Lane To: Peter Eisentraut cc: Andres Freund , pgsql-hackers Subject: Re: warnings for invalid function casts In-reply-to: References: <1e97628e-6447-b4fd-e230-d109cec2d584@2ndquadrant.com> <474790.1593526505@sss.pgh.pa.us> <20200630192135.nwlza2u57dy3qej4@alap3.anarazel.de> <496552.1593545900@sss.pgh.pa.us> Comments: In-reply-to Peter Eisentraut message dated "Fri, 03 Jul 2020 16:04:10 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <931659.1593787200.1@sss.pgh.pa.us> Date: Fri, 03 Jul 2020 10:40:00 -0400 Message-ID: <931660.1593787200@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 2020-06-30 21:38, Tom Lane wrote: >> In any case, I think the issue here is what is the escape hatch for saying >> that "I know this cast is okay, don't warn about it, thanks". Treating >> "void (*) (void)" as special for that purpose is nothing more nor less >> than a kluge, so another compiler might do it differently. Given the >> POSIX restriction, I think we could reasonably use "void *" instead. > I think gcc had to pick some escape hatch that is valid also outside of > POSIX, so they just had to pick something. If we're disregarding > support for these Harvard architecture type things, then we might as > well use void * for easier notation. As long as it's behind a typedef, the code will look the same in any case ;-). > Btw., one of the hunks in my patch was in PL/Python. I have found an > equivalent change in the core Python code, which does make use of void > (*) (void): https://github.com/python/cpython/commit/62be74290aca Given that gcc explicitly documents "void (*) (void)" as being what to use, they're going to have a hard time changing their minds about that ... and gcc is dominant enough in this space that I suppose other compilers would have to be compatible with it. So even though it's theoretically bogus, I suppose we might as well go along with it. The typedef will allow a centralized fix if we ever find a better answer. regards, tom lane